//
//  ProductDetailViewController.m
//  PurchasingMeeting
//
//  Created by zhuang yihang on 7/17/13.
//  Copyright (c) 2013 YX. All rights reserved.
//

#import "ProductDetailViewController.h"
#import "ProductObject.h"
#import "NumberInputView.h"
#import "DataManager.h"
#import "SizeObject.h"
#import "OrderObject.h"
#import "PictureViewController.h"
#import "ShopViewController.h"
#import "FPPopoverController.h"
#import "SuitViewController.h"
#import "DetailcellView.h"
#import "WaitTooles.h"
#import "TipView.h"
#import "TKImageCache.h"
#import "PMGlobal.h"
#import "ZbarViewController.h"
#import "AppManager.h"

#import "FMDatabase.h"

@interface ProductDetailViewController (){
    ProductObject *product_;
    
    TKImageCache *imageCache_;
    
    NSArray* sizeType;
    
    NSString* nowpicUrl;
}

@end

@implementation ProductDetailViewController
@synthesize scroll;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (id)initWithProduct:(ProductObject *)product objtag:(int)objtag tag:(int)tag{
    self = [super init];
    if (self) {
        [self setNavTitle:@"产品详情"];
        obj = product;
        numobjtag = objtag;
        numtag = tag;
        minnum = 5;
        shop = [[DataManager sharedManager]getShopList];
        user = [[DataManager sharedManager]getUserObject];
        
        imageCache_ = [[TKImageCache alloc] initWithCacheDirectoryName:@"image"];
        imageCache_.notificationName = @"product_detail_image";
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(product_detail_image:) name:@"product_detail_image" object:nil];
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showtip:) name:@"showtip" object:nil];
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(setsearchbtn:) name:@"setsearchbtn" object:nil];


    }
    
    return self;
}

- (void)dealloc{
    [imageCache_ cancelOperations];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        self.automaticallyAdjustsScrollViewInsets=NO;
    }
    UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
    [b setBackgroundImage:img forState:UIControlStateNormal];
    b.frame = CGRectMake(10, 10, 99, 37);
    [b setTitle:@"返回" forState:UIControlStateNormal];
    [b addTarget:self action:@selector(issave) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithCustomView:b];
    self.navigationItem.leftBarButtonItem = left;
    
    UIButton *zbar = [UIButton buttonWithType:UIButtonTypeCustom];
    img = [[UIHelper getInstance] getBundleImage:@"zbar.png"];
    [zbar setBackgroundImage:img forState:UIControlStateNormal];
    zbar.frame = CGRectMake(10, 10, img.size.width, img.size.height);
    zbar.tag = 13;
    [zbar addTarget:self action:@selector(zbar:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *r = [[UIBarButtonItem alloc] initWithCustomView:zbar];
    self.navigationItem.rightBarButtonItem = r;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(search:) name:@"search" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss:) name:@"dismiss" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(index1:) name:@"index1" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(coderefresh:) name:@"coderefresh" object:nil];
    
    countnumber = 0;
    similarcountnumber = 0;
    iscopy=NO;
    ismodify=NO;
    totalnum=0;
    isret = NO;
    iscopyall = NO;
    isclear1 = NO;
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    NSString *setsearchstr = [def objectForKey:@"setsearchbtn"];
    if ([setsearchstr isEqualToString:@"1"]) {
        isclick = YES;
    }
    else
    {
        isclick = NO;
    }
    ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
   // [[DataManager sharedManager]checkShop:shopobj];
    numshopid = shopobj.shopID;
    shopidarray = [[NSMutableArray alloc]init];
    countarr = [[NSMutableArray alloc]init];
    bigcountarr = [[NSMutableArray alloc]init];
    jkcountarr = [[NSMutableArray alloc]init];
    sizegroupid = [[NSMutableArray alloc]init];
    
    self.view.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    
#ifdef DHH_iOS
        
    [self iphoneUI:obj shopid:numshopid
          shopname:shopobj.shopName];
#else
    [self ipadUI:obj shopid:numshopid shopname:shopobj.shopName tag:0];
#endif
   // scroll.contentInset = UIEdgeInsetsMake(0, 0, 0, 200);
}
-(void)iphoneUI:(ProductObject *)product shopid:(NSString *)shopid shopname:(NSString *)shopname
{
    numshopid=shopid;
   // totalnum = [[DataManager sharedManager]getOrderAmountWithCode:product Shopid:numshopid];
    order = [[DataManager sharedManager]createOrderByProduct:product ShopId:numshopid];
    
    orders = [[NSMutableArray alloc]init];
    bigorders = [[NSMutableArray alloc]init];
    jkorders = [[NSMutableArray alloc]init];
    
    obj = product;
    [self.view removeAllSubviews];
    
    countnumber = 0;
    similarcountnumber = 0;
    
#ifdef XLarge_ENABLE
    
    bigobj = [[DataManager sharedManager]getProduct:[product.pCode stringByAppendingString:@"K"]withColorID:[NSString stringWithFormat:@"%@", product.pColorCode]];
    jkobj = [[DataManager sharedManager]getProduct:[product.pCode stringByAppendingString:@"JK"]withColorID:[NSString stringWithFormat:@"%@", product.pColorCode]];
    if (bigobj) {
        bigorder = [[DataManager sharedManager]createOrderByProduct:bigobj ShopId:numshopid];
    }
    if (jkobj) {
        jkorder = [[DataManager sharedManager]createOrderByProduct:jkobj ShopId:numshopid];
    }
#endif

    UIImage *img = [[UIHelper getInstance] getBundleImage:@"back.png"];
    UIImageView *back = [[UIImageView alloc]initWithImage:img];
    back.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    [self.view addSubview:back];
    
    UIImage *tintImage = [[UIHelper getInstance] getBundleImage:@"detail_tint.png"];
    tintImage = [tintImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 16, 0, 16)];
    
    tint = [[UIImageView alloc]initWithImage:tintImage];
    tint.width = 1024;
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        tint.top = 64;
    }

    tint.userInteractionEnabled = YES;
    [self.view addSubview:tint];
    
    img = [[UIHelper getInstance] getBundleImage:@"detail_codesearch.png"];
    UIImageView *search = [[UIImageView alloc]initWithImage:img];
    search.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    search.center = CGPointMake(820, tint.height/2);
    [self.view addSubview:search];
    
    UILabel *shoptitle = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, 300, tint.height)];
    shoptitle.backgroundColor = [UIColor clearColor];
    ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
    shoptitle.text = shopobj.shopID;
    shoptitle.textAlignment = UITextAlignmentLeft;
    shoptitle.textColor = [UIColor colorWithRed:207/255.0 green:109/255.0 blue:0 alpha:1];
    [tint addSubview:shoptitle];
    
    img = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
    UIButton *save1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [save1 setBackgroundImage:img forState:UIControlStateNormal];
    save1.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    save1.center = CGPointMake(160, tint.height/2);
    [save1 setTitle:@"保存" forState:UIControlStateNormal];
    save1.titleLabel.textColor = [UIColor whiteColor];
    [save1 addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
    [tint addSubview:save1];
    
    img = [[UIHelper getInstance] getBundleImage:@"detail_copy_iphone.png"];
    /*
    UIButton *copy1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [copy1 setBackgroundImage:img forState:UIControlStateNormal];
    [copy1 setTitle:@"整单复制" forState:UIControlStateNormal];
    copy1.titleLabel.font = [UIFont systemFontOfSize:14];
    copy1.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    copy1.center = CGPointMake(160, tint.height/2);
    copy1.tag = 184001;
    [copy1 addTarget:self action:@selector(copytoothershop:) forControlEvents:UIControlEventTouchUpInside];
    [tint addSubview:copy1];
    */
    
    UIButton *copy = [UIButton buttonWithType:UIButtonTypeCustom];
    [copy setBackgroundImage:img forState:UIControlStateNormal];
    [copy setTitle:@"复制到其他店铺" forState:UIControlStateNormal];
    copy.titleLabel.font = [UIFont systemFontOfSize:12];
    copy.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    copy.center = CGPointMake(250, tint.height/2);
    copy.tag = 184000;
    [copy addTarget:self action:@selector(copytoothershop:) forControlEvents:UIControlEventTouchUpInside];
    [tint addSubview:copy];
    
    scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    scrollview.bounces = NO;
    scrollview.top = tint.bottom;
    scrollview.userInteractionEnabled = YES;
    [self.view addSubview:scrollview];
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap4)];
    [self.view addGestureRecognizer:tap4];
    
    view = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 0, 300, 400)];
    view.userInteractionEnabled = YES;
    view.top = 20;
    [scrollview addSubview:view];
    
    UIView *report = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 35)];
    report.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    report.tag = 180001;
    [view addSubview:report];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap2:)];
    [report addGestureRecognizer:tap];
    
    UILabel *code = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 35)];
    code.backgroundColor = [UIColor clearColor];
    NSString *str = [NSString stringWithFormat:@"%@",obj.pColor];
    code.text = str;
    code.adjustsFontSizeToFitWidth=YES;
    code.textAlignment = NSTextAlignmentCenter;
    [report addSubview:code];
    if ([[obj n_status] intValue]==1) {
        code.textColor = [UIColor redColor];
    }
    
    UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(60, 0, 60, 35)];
    count.backgroundColor = [UIColor clearColor];
   // count.left = right + 10;
    count.text = @"小计";
    count.textColor = [UIColor whiteColor];
    count.textAlignment = NSTextAlignmentCenter;
    [report addSubview:count];
    
    iphonescroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 35, 300, 71)];
    [view addSubview:iphonescroll];
    
    UIView *reportline1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 152, 35)];
    reportline1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline1.top = report.bottom;
   // [iphonescroll addSubview:reportline1];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(75, 0, 1, 70)];
    line.backgroundColor = [UIColor blackColor];
   // [iphonescroll addSubview:line];
    
    UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(152, 0, 1, 70)];
    line2.backgroundColor = [UIColor blackColor];
   // [iphonescroll addSubview:line2];
    
    similar = [[DataManager sharedManager] getSimiliarProduct:obj];
    /*
    //获取有几种板式，普通的为一种，西装有3种A、B、C
    sizeType = [[DataManager sharedManager] getSizeTypeBySizeGroup:obj.pSizeGroupID];
    
    for (int i=0;i<sizeType.count;i++) {
        
        if (![[sizeType objectAtIndex:i] isEqualToString:@""]) {
            UIButton *typeAbtn = [UIButton buttonWithType:UIButtonTypeCustom];
            typeAbtn.frame = CGRectMake(0, 0, 65, 25);
            [typeAbtn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"anniu.png"] forState:UIControlStateNormal];
            [typeAbtn setTitle:[sizeType objectAtIndex:i] forState:UIControlStateNormal];
            typeAbtn.origin = CGPointMake(i*70+20, 0);
            [typeAbtn addTarget:self action:@selector(selectSizeType:) forControlEvents:UIControlEventTouchUpInside];
            [scrollview addSubview:typeAbtn];
            typeAbtn.top = 5;
            typeAbtn.tag = 1100+i;
        }
    }
*/
    totalsizegroupid = [[DataManager sharedManager] getSizeListBySizeGroup:obj.pSizeGroupID SizeType:@""];
    NSArray *sizestatues = [[DataManager sharedManager]issizecancel:obj.pCode colorid:obj.pColorCode];
    for (int i=0;i<sizestatues.count;i++) {
        NSString *size = [sizestatues objectAtIndex:i];
        SizeObject *sizeobj = [totalsizegroupid objectAtIndex:[size intValue]];
        [sizegroupid addObject:sizeobj];
    }
   // NSArray *sizestatues = [[DataManager sharedManager]issizecancel:obj.pCode colorid:obj.pColorCode];
    for (int i = 0; i<sizegroupid.count; i++) {
        
        SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(77*i, 0, 76, 35)];
        label.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        label.text = sizeobject.sSizeName;
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.userInteractionEnabled = YES;
        [iphonescroll addSubview:label];
        
        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap3:)];
        [label addGestureRecognizer:tap3];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(77*(i+1)-1, 0, 1, 71)];
        line.backgroundColor = [UIColor blackColor];
        [iphonescroll addSubview:line];
        
        iphonescroll.contentSize = CGSizeMake(77*(i+1), 71);
        right = 152 + 77*(i+1);
    }
    
    UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, 35, 77*(sizegroupid.count), 1)];
    scrollline1.backgroundColor = [UIColor blackColor];
 //   scrollline1.top = report.bottom-1;
    [iphonescroll addSubview:scrollline1];
    
    UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(801, 0, 199, 35)];
    report1.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    report1.left = right+1;
  //  [iphonescroll addSubview:report1];
    
    UIView *reportline11 = [[UIView alloc]initWithFrame:CGRectMake(801, 105, 199, 35)];
    reportline11.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline11.left = right+1;
    reportline11.top = report1.bottom;
  //  [iphonescroll addSubview:reportline11];
    
    
    UILabel *operate = [[UILabel alloc]initWithFrame:CGRectMake(890, 0, 77, 35)];
    operate.backgroundColor = [UIColor clearColor];
    operate.left = right + 90;
    operate.text = @"操作";
    operate.textColor = [UIColor whiteColor];
    operate.textAlignment = NSTextAlignmentCenter;
  //  [iphonescroll addSubview:operate];
    
    
    UILabel *color1 = [[UILabel alloc]initWithFrame:CGRectMake(75, 35, 75, 35)];
    color1.backgroundColor = [UIColor clearColor];
    color1.text = obj.pColor;
    if ([[obj n_status] intValue]==1) {
        color1.textColor = [UIColor redColor];
    }
    color1.textAlignment = NSTextAlignmentCenter;
  //  [iphonescroll addSubview:color1];
    input = [[NumberInputView alloc]initWithFrame:CGRectMake(0, 60, 320, 220)];
    input.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1.0];
    input.delegate = self;
    input.top = self.view.bottom;
    input.tag = 180002;
    [self.view addSubview:input];
  //  UIView* dummyView = [[UIView alloc] initWithFrame:CGRectZero];
    for(int i=0;i<sizegroupid.count;i++)
    {
        /*
        NSString *statue;
        if (sizestatues.count>0 && i<sizestatues.count) {
            statue = [sizestatues objectAtIndex:i];
        }
         */
        SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
        NSString * sizeno = sizeobject.sSizeNo;
        UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(77*i, 36, 76, 35)];
        textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        textfield.delegate = self;
        NSString *num = [NSString stringWithFormat:@"%d",[order getOrder:sizeno withShopID:numshopid]];
        textfield.text = num;
        if ([obj.n_status intValue] == 1)
        {
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap6)];
            [textfield addGestureRecognizer:tap];
        }
        /*
        else if ([statue boolValue]==YES) {
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap5)];
            [textfield addGestureRecognizer:tap];
        }
         */
        textfield.tag = i+10;
        textfield.inputView = input;
        textfield.textAlignment = NSTextAlignmentCenter;
        textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [iphonescroll addSubview:textfield];
        countnumber += [order getOrder:sizeno withShopID:numshopid];
    }
    
    UILabel *countnum = [[UILabel alloc]initWithFrame:CGRectMake(120, 0, 60, 35)];
    countnum.backgroundColor = [UIColor clearColor];
  //  countnum.left = right + 10;
    countnum.tag = 110000;
    NSString *number = [NSString stringWithFormat:@"%d",countnumber];
    countnum.text = number;
    countnum.textColor = [UIColor blackColor];
    countnum.textAlignment = NSTextAlignmentCenter;
    [report addSubview:countnum];
    [countarr addObject:countnum.text];
    totalnum += countnumber;
    
    if (numtag==0) {
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(180, 0, 50, 25);
        // match.left = right + 70;
        match.centerY = report.height/2;
        match.tag = 100000;
        [match setTitle:@"搭配" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
        [report addSubview:match];
        
        
        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(240, 0, 50, 25);
        proportion.centerY = report.height/2;
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
       // proportion.tag=20000;
        if ([obj.n_status intValue] == 1){
            proportion.tag = 186000;
        }
        else
        {
            proportion.tag = 20000;
        }
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        
        [report addSubview:proportion];

    }
    else
    {
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
#if ENABLE_RATIO
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(180, 0, 50, 25);
        match.centerY = report.height/2;
        match.tag = 100000;
        [match setTitle:@"配比" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
        [report addSubview:match];
#else
#endif
        

        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(240, 0, 50, 25);
        proportion.centerY = report.height/2;
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
      //  proportion.tag=20000;
        if ([obj.n_status intValue] == 1){
            proportion.tag = 186000;
        }
        else
        {
            proportion.tag = 20000;
        }
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        
        [report addSubview:proportion];
    }
    scrollview.contentSize = CGSizeMake(self.view.width, 141);
    
    for (int i = 0; i<similar.count; i++) {
        ProductObject *simproduct = [similar objectAtIndex:i];
        OrderObject *orderobj = [[DataManager sharedManager]createOrderByProduct:simproduct ShopId:numshopid];
        [orders addObject:orderobj];
        OrderObject *order1 = [orders objectAtIndex:i];
        
        UIScrollView *similarscroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 90+36*i, 300, 72)];
     //   similarscroll.bottom = report.bottom;
        similarscroll.tag = 170001+i;
        similarscroll.hidden = YES;
        [view addSubview:similarscroll];
        
        for (int i = 0; i<sizegroupid.count; i++) {
            
            SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
            
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(77*i, 0, 76, 35)];
            label.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            label.text = sizeobject.sSizeName;
            label.textColor = [UIColor blackColor];
            label.textAlignment = NSTextAlignmentCenter;
            label.userInteractionEnabled = YES;
            [similarscroll addSubview:label];
            
            UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap3:)];
            [label addGestureRecognizer:tap3];
            
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(77*(i+1)-1, 0, 1, 72)];
            line.backgroundColor = [UIColor blackColor];
            [similarscroll addSubview:line];
            
            similarscroll.contentSize = CGSizeMake(77*(i+1), 72);
            right = 152 + 77*(i+1);
        }
        //尺码和数据中间那条线
        UIView *scrollline2 = [[UIView alloc]initWithFrame:CGRectMake(0, 35, 77*(sizegroupid.count), 1)];
        scrollline2.backgroundColor = [UIColor blackColor];
        //   scrollline1.top = report.bottom-1;
        [similarscroll addSubview:scrollline2];
        
        //底端那条线
        UIView *scrollline3 = [[UIView alloc]initWithFrame:CGRectMake(0, 71, 77*(sizegroupid.count), 1)];
        scrollline3.backgroundColor = [UIColor blackColor];
        //   scrollline1.top = report.bottom-1;
        [similarscroll addSubview:scrollline3];
        
      //  NSArray *sizestatues = [[DataManager sharedManager]issizecancel:simproduct.pCode colorid:simproduct.pColorCode];
        for(int j=0;j<sizegroupid.count;j++)
        {
            /*
            NSString *statue;
            if (sizestatues.count>0 && j<sizestatues.count) {
                statue = [sizestatues objectAtIndex:i];
            }
             */
            SizeObject *sizeobject = [sizegroupid objectAtIndex:j];
            NSString * sizeno = sizeobject.sSizeNo ;
            UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(77*j, 36, 76, 35)];
            textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            textfield.delegate = self;
            NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
            textfield.text = num;
            if ([obj.n_status intValue] == 1)
            {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap6)];
                [textfield addGestureRecognizer:tap];
            }
            /*
            else if ([statue boolValue]==YES) {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap5)];
                [textfield addGestureRecognizer:tap];
            }
             */
            textfield.tag = j+100*(i+1);
            textfield.inputView = input;
            textfield.textAlignment = NSTextAlignmentCenter;
            textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [similarscroll addSubview:textfield];
            similarcountnumber += [order1 getOrder:sizeno withShopID:numshopid];
        }
        /*
        for (int j = 0; j<sizegroupid.count; j++) {
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(152+77*(j+1), 0, 1, 35)];
            line.backgroundColor = [UIColor blackColor];
            line.top = report.top;
            [similarscroll addSubview:line];
            
        }
        */
        UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, 35, 77*(sizegroupid.count), 1)];
        scrollline1.backgroundColor = [UIColor blackColor];
        [report addSubview:scrollline1];
        
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(800, 0, 1, 35)];
        line1.backgroundColor = [UIColor blackColor];
        line1.top = report.top;
        line1.left = right;
      //  [iphonescroll addSubview:line1];
        
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(0, line1.bottom, 152, 1)];
        line2.backgroundColor = [UIColor blackColor];
        line2.top = report.bottom-1;
      //  [iphonescroll addSubview:line2];
        
        UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(801, 90+i*35, 199, 35)];
        report1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        report1.left = right + 1;
      //  [iphonescroll addSubview:report1];
        
        UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(801, line1.bottom, 199, 1)];
        line3.backgroundColor = [UIColor blackColor];
        line3.top = report1.bottom-1;
        line3.left = right + 1;
      //  [iphonescroll addSubview:line3];
        
        
        scrollview.contentSize = CGSizeMake(self.view.width, 141 + 35*(i+1));
    }
    
    for (int i = 0; i<similar.count; i++) {
        ProductObject *simproduct = [similar objectAtIndex:i];
        UIView *report = [[UIView alloc]initWithFrame:CGRectMake(0, 126+36*i, 300, 36)];
        report.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        report.tag = 160001+i;
        [view addSubview:report];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap1:)];
        [report addGestureRecognizer:tap];
        
        UIView *line11 = [[UIView alloc]initWithFrame:CGRectMake(75, 0, 1, 35)];
        line11.backgroundColor = [UIColor blackColor];
        line11.top = report.top;
        //  [iphonescroll addSubview:line11];
        
        UIView *line12 = [[UIView alloc]initWithFrame:CGRectMake(152, 0, 1, 35)];
        line12.backgroundColor = [UIColor blackColor];
        line12.top = report.top;
        //  [iphonescroll addSubview:line12];
        
        UILabel *code = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 35)];
        code.backgroundColor = [UIColor clearColor];
        NSString *str = [NSString stringWithFormat:@"%@",simproduct.pColor];
        code.text = str;
        code.adjustsFontSizeToFitWidth=YES;
        code.textAlignment = NSTextAlignmentCenter;
        [report addSubview:code];

        
        UILabel *color1 = [[UILabel alloc]initWithFrame:CGRectMake(75, 105, 75, 35)];
        color1.backgroundColor = [UIColor clearColor];
        color1.text = simproduct.pColor;
        color1.top = report.top;
        color1.textAlignment = NSTextAlignmentCenter;
        //  [iphonescroll addSubview:color1];
        if ([[simproduct n_status] intValue]==1) {
            code.textColor = [UIColor redColor];
            color1.textColor = code.textColor;
        }
        
        UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(60, 0, 60, 35)];
        count.backgroundColor = [UIColor clearColor];
        // count.left = right + 10;
        count.text = @"小计";
        count.textColor = [UIColor blackColor];
        count.textAlignment = NSTextAlignmentCenter;
        [report addSubview:count];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, report.width, 1)];
        line.backgroundColor = [UIColor blackColor];
        line.bottom = report.height;
        [report addSubview:line];
        
        UILabel *countnumone = [[UILabel alloc]initWithFrame:CGRectMake(120, 0, 60, 35)];
        countnumone.backgroundColor = [UIColor clearColor];
        //  countnumone.left = right + 10;
        countnumone.tag = 110001+i;
        NSString *number = [NSString stringWithFormat:@"%d",similarcountnumber];
        countnumone.text = number;
        countnumone.textAlignment = NSTextAlignmentCenter;
        [report addSubview:countnumone];
        [countarr addObject:countnumone.text];
        totalnum += similarcountnumber;
        if (numtag==0) {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(180, 95+35*i, 50, 25);
            match.centerY = report.height/2;
            match.tag = 100001+i;
            [match setTitle:@"搭配" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
            [report addSubview:match];
            
            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(240, 95+35*i, 50, 25);
            proportion.centerY = report.height/2;
            //  proportion.left = right + 110;
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            proportion.tag=21000+i;
            if ([obj.n_status intValue] == 1){
                proportion.tag = 186001+i;
            }
            else
            {
                proportion.tag = 21000+i;
            }
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            [report addSubview:proportion];
        }
        else
        {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
#if ENABLE_RATIO
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(180, 95+35*i, 50, 25);
            match.centerY = report.height/2;
            match.tag = 100001+i;
            [match setTitle:@"配比" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
            [report addSubview:match];
#else
#endif
            
            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(240, 95+35*i, 50, 25);
            proportion.centerY = report.height/2;
            //  proportion.left = right + 110;
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
           // proportion.tag=21000+i;
            if ([obj.n_status intValue] == 1){
                proportion.tag = 186001+i;
            }
            else
            {
                proportion.tag = 21000+i;
            }
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            [report addSubview:proportion];
        }
    }
    
    UIView *reportline2 = [[UIView alloc]initWithFrame:CGRectMake(0, 105, 300, 20)];
    reportline2.backgroundColor = [UIColor colorWithRed:57/255.0 green:14/255.0 blue:0 alpha:1];
    reportline2.tag = 180000;
    // reportline2.width = right + 200;
    [view addSubview:reportline2];
    
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 120, 15)];
    title.backgroundColor = [UIColor clearColor];
    title.top = scrollview.contentSize.height+15;
    title.left = 10;
    title.textColor = [UIColor blackColor];
    NSString *minnumstr = [NSString stringWithFormat:@"最小起订量：%d件",[obj.item5 intValue]];
    title.text = minnumstr;
    title.font = [UIFont systemFontOfSize:14];
    [scrollview addSubview:title];
    
    UILabel *title1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 120, 15)];
    title1.top = title.top+20;
    title1.left = title.left;
    title1.backgroundColor = [UIColor clearColor];
    title1.textColor = [UIColor blackColor];
    title1.font = [UIFont systemFontOfSize:14];
    NSString *minnumstr1 = [NSString stringWithFormat:@"订货倍数：%d",[obj.n_beis intValue]];
    title1.text = minnumstr1;
    [scrollview addSubview:title1];
    
    totallabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 15)];
    totallabel.top = title.top;
    totallabel.left =title.right+10;
    totallabel.backgroundColor = [UIColor clearColor];
    totallabel.textColor = [UIColor blackColor];
    totallabel.text = str;
    totallabel.font = [UIFont systemFontOfSize:14];
    totallabel.tag = 160000;
    [scrollview addSubview:totallabel];
    [self refreshTotalQuantityLabel];

    UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
    UIButton *save = [UIButton buttonWithType:UIButtonTypeCustom];
    [save setBackgroundImage:img3 forState:UIControlStateNormal];
    save.frame = CGRectMake(0, 0, img3.size.width, img3.size.height);
    save.top = title.top+5;
    save.right = scrollview.right-10;
    [save setTitle:@"保存" forState:UIControlStateNormal];
    save.titleLabel.textColor = [UIColor whiteColor];
    [save addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
    [scrollview addSubview:save];
    
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, scrollview.width, 1)];
    line1.backgroundColor = [UIColor blackColor];
    line1.top = scrollview.contentSize.height+60;
    [scrollview addSubview:line1];

    scrollview.contentSize = CGSizeMake(self.view.width, scrollview.contentSize.height+30);
    
    detail = [[UIImageView alloc]initWithImage:[[UIHelper getInstance] getBundleImage:@"clear.png"]];
    detail.frame = CGRectMake(10, 360, 300, 260);
    detail.top = scrollview.contentSize.height+35;
    detail.userInteractionEnabled = YES;
    [scrollview addSubview:detail];
    
    UILabel *titlecell = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, 30)];
    titlecell.backgroundColor = [UIColor clearColor];
    titlecell.center = CGPointMake(self.view.width/2-90, 15);
    titlecell.text = @"商品详情";
    titlecell.top = scrollview.contentSize.height + 35;
    titlecell.textColor = [UIColor colorWithRed:57/255.0 green:14/255.0 blue:0 alpha:1.0];
    titlecell.textAlignment = NSTextAlignmentCenter;
    [scrollview addSubview:titlecell];
    
    UIImage *img2 = [[UIHelper getInstance] getBundleImage:@"collect_image.png"];
    for (int i = 0; i<5; i++) {
        UIButton *collect = [UIButton buttonWithType:UIButtonTypeCustom];
        if (i<[[DataManager sharedManager]productIsFavorite:obj Shopid:numshopid]) {
            [collect setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_redimage.png"] forState:UIControlStateNormal];
        }
        else
        {
            [collect setBackgroundImage:img2 forState:UIControlStateNormal];
        }
        collect.frame = CGRectMake(i*40+110, 0, img2.size.width, img2.size.height);
        collect.tag = i+10000;
        // collect.right = productImageV.right-5;
        collect.top = scrollview.contentSize.height + 35;
        [collect addTarget:self action:@selector(collect:) forControlEvents:UIControlEventTouchUpInside];
        [scrollview addSubview:collect];
    }
    
    img = [[UIHelper getInstance] getBundleImage:@"detail_titleline.png"];
    UIImageView *titleline = [[UIImageView alloc]initWithImage:img];
    titleline.frame = CGRectMake(0, 0, detail.width, img.size.height);
    titleline.center = CGPointMake(self.view.width/2, 34);
    titleline.top = titlecell.bottom;
    [scrollview addSubview:titleline];
    
    int bottom=0;
    NSArray *array = [[DataManager sharedManager]getSpdmOrder];
    for (int i = 0; i<array.count; i++) {
        DetailcellView *cell = [[DetailcellView alloc]initWithFrame:CGRectMake(0, 0, detail.width, 0)];
        cell.centerX = self.view.width/2;
        cell.top=titleline.bottom+bottom;
        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap3:)];
        [cell addGestureRecognizer:tap3];
        NSDictionary *dic = [array objectAtIndex:i];
        NSString *titlename = [dic objectForKey:@"c_spdmmc"];
        NSString *name = [dic objectForKey:@"c_spdmzd"];
        NSString *isvisible = [dic objectForKey:@"b_visible"];
        if ([isvisible isEqualToString:@"0"]) {
            [cell removeFromSuperview];
            continue;
        }
        NSString *content = [[DataManager sharedManager]getspdmorder:obj titlename:name];
        str = [NSString stringWithFormat:@"%@：%@",titlename,content];
        if ([content isEqualToString:@""]) {
            [cell removeFromSuperview];
            continue;
        }

        CGSize s = [str sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(cell.width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
        cell.title.height = s.height;
        cell.height = s.height+1;
        cell.title.text = str;
        bottom=cell.bottom-titleline.bottom;
        [scrollview addSubview:cell];
    }
    scrollview.contentSize = CGSizeMake(scrollview.width, scrollview.contentSize.height+bottom+20);

    img = [[UIHelper getInstance] getBundleImage:@"coatimage.png"];

    UIImageView *coatimage = [[UIImageView alloc]initWithImage:[[UIHelper getInstance] getBundleImage:@"clear.png"]];
    coatimage.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    coatimage.top = scrollview.contentSize.height+35;
    coatimage.centerX = self.view.width/2;
    coatimage.userInteractionEnabled = YES;
    
    
//    UIView *container = [[UIView alloc] initWithFrame:coatimage.bounds];
//    [scrollview addSubview:container];
//    container.userInteractionEnabled = YES;
//    container.top = scrollview.contentSize.height+20;
//    container.centerX = self.view.width/2;
    
    [scrollview addSubview:coatimage];
    
    UIImageView *productImageV = [[UIImageView alloc] initWithFrame:CGRectMake(13, 17, 272, 266)];
    [coatimage addSubview:productImageV];
   // UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
   // [productImageV addGestureRecognizer:tapGes];
   // NSString *url = [NSString stringWithFormat:@"%@",obj.pThumbURL];
   // NSString * path = [[[PMGlobal getInstance] getImageURL] stringByAppendingPathComponent:url];
   // productImageV.image = [imageCache_ imageForKey:obj.pThumbURL url:[NSURL URLWithString:path] queueIfNeeded:YES tag:0];
    productImageV.userInteractionEnabled = YES;
    productImageV.clipsToBounds = YES;
    productImageV.contentMode = UIViewContentModeScaleAspectFit;
    productImageV.backgroundColor = [UIColor clearColor];
    
    UIImageView *clear = [[UIImageView alloc] initWithFrame:CGRectMake(13, 17, 272, 214)];
    [coatimage addSubview:clear];
    clear.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
    [clear addGestureRecognizer:tapGes];
    clear.clipsToBounds = YES;
    clear.contentMode = UIViewContentModeScaleAspectFill;
    clear.backgroundColor = [UIColor clearColor];
    /*
    UIImage *img1 = [[UIHelper getInstance] getBundleImage:@"collectbar.png"];
    UIImageView *collectback = [[UIImageView alloc]initWithImage:img1];
    collectback.frame = CGRectMake(0, 0, img1.size.width, img1.size.height);
    collectback.right = productImageV.right;
    collectback.bottom = productImageV.bottom;
    collectback.userInteractionEnabled = YES;
    [coatimage addSubview:collectback];
    */
    productImage_ = productImageV;
    NSString *url = [NSString stringWithFormat:@"%@",obj.pThumbURL];
    nowpicUrl = obj.pURL;
    NSString * path = [[[PMGlobal getInstance] getImageURL] stringByAppendingPathComponent:url];
    
    
    if ([[PMGlobal getInstance]isImageEnable]) {
        productImage_.image = [imageCache_ imageForKey:obj.pThumbURL url:[NSURL URLWithString:path] queueIfNeeded:YES tag:0];
        if (!productImage_.image) {
                    productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
        }
    }else{
        productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
    }
    


    
    
    img = [[UIHelper getInstance] getBundleImage:@"detail_coatimagebar.png"];
    UIImageView *imagebar = [[UIImageView alloc]initWithImage:img];
    imagebar.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    imagebar.center = CGPointMake(coatimage.width/2, 310);
    [coatimage addSubview:imagebar];
    
    sale = [[UILabel alloc]initWithFrame:CGRectMake(15, 293, 100, 30)];
    sale.backgroundColor = [UIColor clearColor];
    sale.textColor = [UIColor whiteColor];
    NSString *salestr = [NSString stringWithFormat:@"￥%.0f",obj.pSale];
    sale.text = salestr;
    [coatimage addSubview:sale];
    
    code1 = [[UILabel alloc]initWithFrame:CGRectMake(130, 293, 100, 30)];
    code1.backgroundColor = [UIColor clearColor];
    code1.textColor = [UIColor blackColor];
    code1.text = obj.pCode;
    code1.adjustsFontSizeToFitWidth=YES;
    code1.textAlignment = NSTextAlignmentCenter;
    code1.centerX = 150;
    [coatimage addSubview:code1];
    
    scrollview.contentSize = CGSizeMake(self.view.width, scrollview.contentSize.height + coatimage.height+170);
    /*
    //如果有加大码则加载加大码视图
    if (bigobj) {
        bigView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 1024, 230)];
        bigView.userInteractionEnabled = YES;
        bigView.bounces = NO;
        [self.view addSubview:bigView];
        
        [self addBigObj:(NSString *)shopid shopname:(NSString *)shopname];
        
        view.height = 120;
        bigView.height = 120;
        
        bigView.top = view.bottom+5;
        
        
    }
    
    //如果有加裤则显示加裤标签，加裤没有加大码之分
    jkobj = [[DataManager sharedManager] getProductObjectByName:[product.pCode stringByAppendingString:@"JK"] andColor:product.pColorCode];
    
    if (jkobj) {
        UIButton *typejkbtn = [UIButton buttonWithType:UIButtonTypeCustom];
        typejkbtn.frame = CGRectMake(0, 0, 65, 25);
        [typejkbtn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"anniu.png"] forState:UIControlStateNormal];
        [typejkbtn setTitle:@"加裤" forState:UIControlStateNormal];
        typejkbtn.origin = CGPointMake(sizeType.count*70+20, 0);
        [typejkbtn addTarget:self action:@selector(selectSizeType:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:typejkbtn];
        typejkbtn.top = tint.bottom+5;
        typejkbtn.tag = 1200;
        
        jkView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 1024, 230)];
        jkView.userInteractionEnabled = YES;
        jkView.bounces=NO;
        [self.view addSubview:jkView];
        
        [self addJKObj:(NSString *)shopid shopname:(NSString *)shopname];
        
        jkView.top = view.top;
        
        [jkView setHidden:YES];
    }
     */
}


-(void)ipadUI:(ProductObject *)product shopid:(NSString *)shopid shopname:(NSString *)shopname tag:(int)tag
{
    [sizegroupid removeAllObjects];
    numshopid=shopid;
   // totalnum = [[DataManager sharedManager]getOrderAmountWithCode:product Shopid:numshopid];
    totalnum = 0;
    order = [[DataManager sharedManager]createOrderByProduct:product ShopId:numshopid];
    
    orders = [[NSMutableArray alloc]init];
    bigorders = [[NSMutableArray alloc]init];
    jkorders = [[NSMutableArray alloc]init];

    obj = product;
    [self.view removeAllSubviews];
    countnumber = 0;
    similarcountnumber = 0;
    
    
#ifdef XLarge_ENABLE
    additionProduct = [[DataManager sharedManager] getAdditionalProduct:product.pCode withColorID:product.pColorCode];
    bigobj = [additionProduct objectForKey:@"3"];
    jkobj = [additionProduct objectForKey:@"4"];
    if (bigobj) {
        bigorder = [[DataManager sharedManager]createOrderByProduct:bigobj ShopId:numshopid];
    }
    if (jkobj) {
        jkorder = [[DataManager sharedManager]createOrderByProduct:jkobj ShopId:numshopid];
    }
#endif

    
    UIImage *tintImage = [[UIHelper getInstance] getBundleImage:@"detail_tint1.png"];
    tintImage = [tintImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 16, 0, 16)];
    
    tint = [[UIImageView alloc]initWithImage:tintImage];
    tint.width = 1024;
    tint.height = 60;
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        tint.top = 64;
    }

    tint.userInteractionEnabled = YES;
    [self.view addSubview:tint];

    
    view = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 1024, 230)];
    view.userInteractionEnabled = YES;
    view.bounces = NO;
    view.top = tint.bottom+15;
    [self.view addSubview:view];
    
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"anniu.png"];

    
    UIButton *copy = [UIButton buttonWithType:UIButtonTypeCustom];
    [copy setBackgroundImage:img forState:UIControlStateNormal];
    [copy setTitle:@"复制到其他店铺" forState:UIControlStateNormal];
    copy.titleLabel.font = [UIFont systemFontOfSize:14];
    copy.frame = CGRectMake(0, 0, [[UIHelper getInstance] getBundleImage:@"detail_copy.png"].size.width, 40);
    copy.center = CGPointMake(650, tint.height/2);
    copy.tag = 184000;
    [copy addTarget:self action:@selector(copytoothershop:) forControlEvents:UIControlEventTouchUpInside];
    [tint addSubview:copy];
    
    
    codesearch = [[UITextField alloc]initWithFrame:CGRectMake(780, 12, 115, tint.height)];
    codesearch.backgroundColor = [UIColor clearColor];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        codesearch.center = CGPointMake(830, tint.height/2);
    }
    else
    {
        codesearch.center = CGPointMake(830, tint.height/2+18);
    }
    codesearch.left = copy.right + 44;
    codesearch.inputView = [[UIView alloc]initWithFrame:CGRectZero];
    codesearch.delegate = self;
    codesearch.tag = 1000;
    
    if (isclick==YES) {
        codesearch.placeholder = SEARCH_CODENAME;
    }
    else
    {
        codesearch.placeholder = SEARCH_SIMCODE;
    }
    codesearch.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    [tint addSubview:codesearch];
    
    
    UIImage *searchImg = [[UIHelper getInstance] getBundleImage:@"detail_codesearch.png"];
    UIImageView *search = [[UIImageView alloc]initWithImage:searchImg];
    search.frame = CGRectMake(0, 0, searchImg.size.width*4/3, searchImg.size.height*4/3);
    search.center = CGPointMake(823, tint.height/2);
    search.left = codesearch.left-38;
    search.userInteractionEnabled=YES;
    [tint addSubview:search];
    [tint bringSubviewToFront:codesearch];
    
    UIView *clickview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    clickview.backgroundColor = [UIColor clearColor];
    clickview.userInteractionEnabled=YES;
    [search addSubview:clickview];
    
    UITapGestureRecognizer *clicktap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clicktap:)];
    [clickview addGestureRecognizer:clicktap];

    UIButton *comfirmSearch = [UIButton buttonWithType:UIButtonTypeCustom];
    comfirmSearch.frame = CGRectMake(0, 0, 60, 40);
    [comfirmSearch setBackgroundImage:img forState:UIControlStateNormal];
    [comfirmSearch setTitle:@"搜索" forState:UIControlStateNormal];
    comfirmSearch.center = CGPointMake(960, tint.height/2);
    comfirmSearch.left = codesearch.right+6;
    [comfirmSearch addTarget:self action:@selector(comfirmSearch:) forControlEvents:UIControlEventTouchUpInside];
    [tint addSubview:comfirmSearch];
    
    UIButton *select = [UIButton buttonWithType:UIButtonTypeCustom];
    select.frame = CGRectMake(0, 0, 80, 40);
    [select setBackgroundImage:img forState:UIControlStateNormal];
    [select setTitle:@"切换" forState:UIControlStateNormal];
    select.center = CGPointMake(960, tint.height/2);
    select.left = comfirmSearch.right+5;
    [select addTarget:self action:@selector(selectcode:) forControlEvents:UIControlEventTouchUpInside];
    [tint addSubview:select];
    
 
    //暂时先屏蔽多店铺选择
    UILabel *shoptitle = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, 300, tint.height)];
    shoptitle.backgroundColor = [UIColor clearColor];
    ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
    NSString *str = [NSString stringWithFormat:@"%@%@",shopobj.shopID,shopobj.shopName];
    shoptitle.text = str;
    shoptitle.textAlignment = UITextAlignmentLeft;
    shoptitle.textColor = [UIColor whiteColor];
    [tint addSubview:shoptitle];
    
    UIView *report = [[UIView alloc]initWithFrame:CGRectMake(20, 0, 152, 35)];
    if ([[[PMGlobal getInstance]gettype] isEqualToString:@"type1"]) {
        report.backgroundColor = [UIColor colorWithRed:35/255.0 green:6/255.0 blue:6/255.0 alpha:1];
    }
    else
    {
        report.backgroundColor = [UIColor colorWithRed:175/255.0 green:145/255.0 blue:105/255.0 alpha:1];
    }
    [view addSubview:report];
    
    UIView *reportline1 = [[UIView alloc]initWithFrame:CGRectMake(20, 0, 152, 35)];
    reportline1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline1.top = report.bottom;
    [view addSubview:reportline1];
    
    UILabel *reportline2 = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 980, 20)];
    if ([[[PMGlobal getInstance]gettype] isEqualToString:@"type1"]) {
        reportline2.backgroundColor = [UIColor colorWithRed:35/255.0 green:6/255.0 blue:6/255.0 alpha:1];
    }
    else
    {
        reportline2.backgroundColor = [UIColor colorWithRed:209/255.0 green:194/255.0 blue:176/255.0 alpha:1];
    }
    reportline2.text = @"同款其它";
    reportline2.textAlignment = UITextAlignmentCenter;
    reportline2.textColor = [UIColor blackColor];
    
    reportline2.top = reportline1.bottom;
    [view addSubview:reportline2];
    
    self.scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(172, 0, 630, view.height+200)];
    self.scroll.alwaysBounceVertical = NO;
    self.scroll.alwaysBounceHorizontal = YES;
    self.scroll.showsHorizontalScrollIndicator = NO;
    self.scroll.bounces = NO;
    [view addSubview:self.scroll];
    /*
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(95, 0, 1, 70)];
    line.backgroundColor = [UIColor blackColor];
    [view addSubview:line];
    */
    UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(172, 0, 1, 70)];
    line2.backgroundColor = [UIColor blackColor];
    [view addSubview:line2];
    
    similar = [[DataManager sharedManager] getSimiliarProduct:obj];
    
    
    //获取有几种板式，普通的为一种，西装有3种A、B、C
    sizeType = [[DataManager sharedManager] getSizeTypeBySizeGroup:obj.pSizeGroupID];
    if (sizeType.count>0) {
    for (int i=0;i<sizeType.count;i++) {
        if (![[sizeType objectAtIndex:i] isEqualToString:@""]) {
            UIButton *typeAbtn = [UIButton buttonWithType:UIButtonTypeCustom];
            typeAbtn.frame = CGRectMake(0, 0, 80, 25);
            [typeAbtn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"anniu.png"] forState:UIControlStateNormal];
            [typeAbtn setTitle:[sizeType objectAtIndex:i] forState:UIControlStateNormal];
            typeAbtn.origin = CGPointMake(i*85+20, 0);
            [typeAbtn addTarget:self action:@selector(selectSizeType:) forControlEvents:UIControlEventTouchUpInside];
            [self.view addSubview:typeAbtn];
            typeAbtn.top = tint.bottom+5;
            typeAbtn.tag = 1100+i;
        }
    }
        totalsizegroupid = [[DataManager sharedManager] getSizeListBySizeGroup:obj.pSizeGroupID SizeType:[sizeType objectAtIndex:0]];
        NSArray *sizestatues = [[DataManager sharedManager]issizecancel:obj.pCode colorid:obj.pColorCode];
        for (int i=0;i<totalsizegroupid.count;i++) {
            SizeObject *sizeobj = [totalsizegroupid objectAtIndex:i];
            
            BOOL isValid = NO;
            for (int j = 0; j < sizestatues.count; j++) {
                NSString *size = [sizestatues objectAtIndex:j];
                if ([size intValue] == [sizeobj.sSizeNo intValue]) {
                    isValid = YES;
                    break;
                }
            }
            
            if (isValid) {
                [sizegroupid addObject:sizeobj];
            }
            
        }
    for (int i = 0; i<sizegroupid.count; i++) {
        
        SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
        if (sizegroupid.count<10) {
            width = self.scroll.width/sizegroupid.count;
        }
        else
        {
            width = 70;
        }
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(width*i+1, 0, width-1, 35)];
        if ([[[PMGlobal getInstance]gettype] isEqualToString:@"type1"]) {
            label.backgroundColor = [UIColor colorWithRed:35/255.0 green:6/255.0 blue:6/255.0 alpha:1];
        }
        else
        {
            label.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
        }
        label.text = sizeobject.sSizeName;
        label.textColor = [UIColor whiteColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.tag = 1500+i;
        [self.scroll addSubview:label];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(width*(i+1), 0, 1, 70)];
        line.backgroundColor = [UIColor blackColor];
        [self.scroll addSubview:line];
        
        self.scroll.contentSize = CGSizeMake(width*(i+1), 70);
    }
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 70)];
    line1.backgroundColor = [UIColor blackColor];
    [view addSubview:line1];
    
    UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(803, 0, 199, 35)];
    if ([[[PMGlobal getInstance]gettype] isEqualToString:@"type1"]) {
        report1.backgroundColor = [UIColor colorWithRed:35/255.0 green:6/255.0 blue:6/255.0 alpha:1];
    }
    else
    {
        report1.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    }
    [view addSubview:report1];
    
    UIView *reportline11 = [[UIView alloc]initWithFrame:CGRectMake(803, 0, 199, 35)];
    reportline11.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline11.top = report1.bottom;
    [view addSubview:reportline11];
    
    UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(812, 0, 77, 35)];
    count.backgroundColor = [UIColor clearColor];
    count.text = @"小计";
    count.textColor = [UIColor whiteColor];
    count.textAlignment = NSTextAlignmentCenter;
    [view addSubview:count];
    
    UILabel *operate = [[UILabel alloc]initWithFrame:CGRectMake(892, 0, 77, 35)];
    operate.backgroundColor = [UIColor clearColor];
    operate.text = @"操作";
    operate.textColor = [UIColor whiteColor];
    operate.textAlignment = NSTextAlignmentCenter;
    [view addSubview:operate];
    
    UILabel *color1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 35, 150, 35)];
    color1.backgroundColor = [UIColor clearColor];
    color1.text = obj.pColor;
    color1.textAlignment = NSTextAlignmentCenter;
    [view addSubview:color1];
        if ([[obj n_status] intValue]==1) {
            color1.textColor = [UIColor redColor];
        }
    
    
    UIView* dummyView = [[UIView alloc] initWithFrame:CGRectZero];
    for(int i=0;i<sizegroupid.count;i++)
    {
//        NSString *statue;
        /*
        BOOL isstatue;
        for (NSString *statue in sizestatues) {
            if (i==[str intValue]) {
                isstatue = YES;
            }
            else
            {
                isstatue = NO;
            }
        }
         */
//        if (sizestatues.count>0&&i<sizestatues.count) {
//            statue = [sizestatues objectAtIndex:i];
//        }
        SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
        UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(1+ width*i, 35, width-1, 35)];
        textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        textfield.delegate = self;
        NSString *num = [NSString stringWithFormat:@"%d",[order getOrder:sizeobject.sSizeNo withShopID:numshopid]];
        textfield.text = num;
        if ([obj.n_status intValue] == 1)
        {
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap6)];
            [textfield addGestureRecognizer:tap];
        }else{
            if (i==0) {
                if ([obj.n_status intValue]==0) {
                    [textfield becomeFirstResponder];                    
                }

            }
        }
        /*
        else if (isstatue==YES) {
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap5)];
            [textfield addGestureRecognizer:tap];
        }
         */
        textfield.tag = i+10;
        textfield.inputView = dummyView;
        textfield.textAlignment = NSTextAlignmentCenter;
        textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [self.scroll addSubview:textfield];
        countnumber += [order getOrder:sizeobject.sSizeNo withShopID:numshopid];
    }
//    if (countnumber==0) {
//        [order clearOrder];
////        SizeObject *sizeobject = [sizegroupid objectAtIndex:0];
////        [[DataManager sharedManager]deleteOrderItem:order withSizeNo:sizeobject.sSizeNo withTableName:@"g_meeting" Shopid:numshopid];
//    }
    UILabel *countnum = [[UILabel alloc]initWithFrame:CGRectMake(812, 35, 77, 35)];
    countnum.backgroundColor = [UIColor clearColor];
    NSString *number = [NSString stringWithFormat:@"%d",countnumber];
    countnum.text = number;
    countnum.tag = 110000;
    countnum.textAlignment = NSTextAlignmentCenter;
    [view addSubview:countnum];
    [countarr addObject:countnum.text];
    totalnum+=countnumber;
    
    if (numtag==0) {
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(875, 40, 50, 25);
        match.tag = 100000;
        [match setTitle:@"搭配" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:match];
        
        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(930, 40, 50, 25);
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        if ([obj.n_status intValue] == 1){
            proportion.tag = 186000;
        }
        else
        {
            proportion.tag = 20000;
        }
        [view addSubview:proportion];
    }
    else
    {
        
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
#if ENABLE_RATIO
        
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(875, 40, 50, 25);
        if ([obj.n_status intValue] == 1){
            match.tag = 185000;
        }
        else
        {
            match.tag = 100000;
        }
        [match setTitle:@"配比" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:match];
#else
#endif

        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(930, 40, 50, 25);
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:proportion];
        if ([obj.n_status intValue] == 1){
            proportion.tag = 186000;
        }
        else
        {
            proportion.tag = 20000;
        }
    }
    
    //同款不同色
    for (int i = 0; i<similar.count; i++) {
        similarcountnumber = 0;
        ProductObject *simproduct = [similar objectAtIndex:i];
        OrderObject *orderobj = [[DataManager sharedManager]createOrderByProduct:simproduct ShopId:shopid];
        [orders addObject:orderobj];
        OrderObject *order1 = [orders objectAtIndex:i];
        
        UIView *report = [[UIView alloc]initWithFrame:CGRectMake(20, 35*i+reportline2.bottom, 152, 35)];
        report.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        [view addSubview:report];
        /*
        UIView *line11 = [[UIView alloc]initWithFrame:CGRectMake(95, 0, 1, 35)];
        line11.backgroundColor = [UIColor blackColor];
        line11.top = report.top;
        [view addSubview:line11];
        */
        UIView *line12 = [[UIView alloc]initWithFrame:CGRectMake(172, 0, 1, 35)];
        line12.backgroundColor = [UIColor blackColor];
        line12.top = report.top;
        [view addSubview:line12];

        UILabel *color1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 35, 150, 35)];
        color1.backgroundColor = [UIColor clearColor];
        color1.text = simproduct.pColor;
        color1.top = report.top;
        color1.textAlignment = NSTextAlignmentCenter;
        [view addSubview:color1];
        
        if ([[simproduct n_status] intValue]==1) {
            color1.textColor = [UIColor redColor];
        }
        
      //  NSArray *sizestatues = [[DataManager sharedManager]issizecancel:simproduct.pCode colorid:simproduct.pColorCode];
        for(int j=0;j<sizegroupid.count;j++)
        {
//            NSString *statue;
            /*
            BOOL isstatue;
            for (NSString *statue in sizestatues) {
                if (i==[str intValue]) {
                    isstatue = YES;
                }
                else
                {
                    isstatue = NO;
                }
            }
             */
//            if (sizestatues.count>0 && j<sizestatues.count) {
//                statue = [sizestatues objectAtIndex:j];
//            }
            SizeObject *sizeobject = [sizegroupid objectAtIndex:j];
            NSString * sizeno = sizeobject.sSizeNo ;
            UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(1 + width*j, 0, width-1, 35)];
            textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            textfield.delegate = self;
            NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
            textfield.text = num;
            if ([simproduct.n_status intValue] == 1)
            {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap6)];
                [textfield addGestureRecognizer:tap];
            }
            /*
            else if (isstatue==YES) {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap5)];
                [textfield addGestureRecognizer:tap];
            }
             */
            textfield.tag = j+100*(i+1);
            textfield.top = report.top;
            textfield.inputView = dummyView;
            textfield.textAlignment = NSTextAlignmentCenter;
            textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [self.scroll addSubview:textfield];
            similarcountnumber += [order1 getOrder:sizeno withShopID:numshopid];

        }
        self.scroll.contentSize = CGSizeMake(self.scroll.contentSize.width, 95+(i*35));
        for (int j = 0; j<sizegroupid.count; j++) {
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(width*(j+1), 0, 1, 35)];
            line.backgroundColor = [UIColor blackColor];
            line.top = report.top;
            [self.scroll addSubview:line];
            
        }
        UIView *scrollline = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 35)];
        scrollline.backgroundColor = [UIColor blackColor];
        scrollline.top = report.top;
        [view addSubview:scrollline];
        
        UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, line1.bottom, width*(sizegroupid.count), 1)];
        scrollline1.backgroundColor = [UIColor blackColor];
        scrollline1.top = report.bottom-1;
        [self.scroll addSubview:scrollline1];
        
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 35)];
        line1.backgroundColor = [UIColor blackColor];
        line1.top = report.top;
        [view addSubview:line1];
        
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(20, line1.bottom, 152, 1)];
        line2.backgroundColor = [UIColor blackColor];
        line2.top = report.bottom-1;
        [view addSubview:line2];
        
        UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(803, 90+i*35, 199, 35)];
        report1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        [view addSubview:report1];
        
        UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(803, line1.bottom, 199, 1)];
        line3.backgroundColor = [UIColor blackColor];
        line3.top = report1.bottom-1;
        [view addSubview:line3];
        
//        if (similarcountnumber==0) {
//            OrderObject *simorder = [orders objectAtIndex:i];
//            [simorder clearOrder];
////            SizeObject *sizeobject = [sizegroupid objectAtIndex:0];
////            [[DataManager sharedManager]deleteOrderItem:simorder withSizeNo:sizeobject.sSizeNo withTableName:@"g_meeting" Shopid:numshopid];
//        }
        
        UILabel *countnumone = [[UILabel alloc]initWithFrame:CGRectMake(812, 90+i*35, 77, 35)];
        countnumone.backgroundColor = [UIColor clearColor];
        NSString *number = [NSString stringWithFormat:@"%d",similarcountnumber];
        countnumone.text = number;
        countnumone.textAlignment = NSTextAlignmentCenter;
        countnumone.tag = 110001+i;
        [view addSubview:countnumone];
        [countarr addObject:countnumone.text];
        totalnum+=similarcountnumber;
        
        if (numtag==0) {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(875, 95+35*i, 50, 25);
            match.tag = 100001+i;
            [match setTitle:@"搭配" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:match];
            
            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(930, 95+35*i, 50, 25);
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            if ([simproduct.n_status intValue] == 1){
                proportion.tag = 186001+i;
            }
            else
            {
                proportion.tag = 21000+i;
            }
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            
            [view addSubview:proportion];
        }
        else
        {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
#if ENABLE_RATIO
            
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(875, 95+35*i, 50, 25);
            if ([simproduct.n_status intValue] == 1){
                match.tag = 185001+i;
            }
            else
            {
                match.tag = 100001+i;
            }
            [match setTitle:@"配比" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:match];
#else
#endif

            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(930, 95+35*i, 50, 25);
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            if ([simproduct.n_status intValue] == 1){
                proportion.tag = 186001+i;
            }
            else
            {
                proportion.tag = 21000+i;
            }
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            
            [view addSubview:proportion];
        }
    }
        
    //商品信息
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(20, 320, 150, 40)];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        title.top = 320+64;
    }
    title.backgroundColor = [UIColor clearColor];
    title.textColor = [UIColor blackColor];
    NSString *minnumstr = [NSString stringWithFormat:@"最小起订量：%d件",[obj.item5 intValue]];
    title.text = minnumstr;
    [self.view addSubview:title];
        
    UILabel *title1 = [[UILabel alloc]initWithFrame:CGRectMake(230, 320, 150, 40)];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        title1.top = 320+64;
    }
    title1.backgroundColor = [UIColor clearColor];
    title1.textColor = [UIColor blackColor];
    NSString *minnumstr1 = [NSString stringWithFormat:@"订货倍数：%d",[obj.n_beis intValue]];
    title1.text = minnumstr1;
    [self.view addSubview:title1];
        
    totallabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 320, 200, 40)];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        totallabel.top = 320+64;
    }
    totallabel.backgroundColor = [UIColor clearColor];
    totallabel.centerX = 512;
    totallabel.textColor = [UIColor blackColor];
    totallabel.tag = 160000;
    [self.view addSubview:totallabel];
        [self refreshTotalQuantityLabel];
    
    UIButton *save = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
    [save setBackgroundImage:img forState:UIControlStateNormal];
    save.frame = CGRectMake(860, 315, 136, 42);
        save.titleLabel.font = [UIFont boldSystemFontOfSize:25];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        save.top = 315+64;
    }
    [save setTitle:@"保存" forState:UIControlStateNormal];
    save.titleLabel.textColor = [UIColor whiteColor];
    [save addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:save];
    
    view.contentSize = CGSizeMake(view.width, self.scroll.contentSize.height+80);
    
    img = [[UIHelper getInstance] getBundleImage:@"detail_background.jpg"];
    UIImageView *background = [[UIImageView alloc]initWithImage:img];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        background.frame = CGRectMake(0, 360+64, img.size.width, img.size.width);
    }
    else
    {
        background.frame = CGRectMake(0, 360, img.size.width, img.size.width);
    }
    [self.view addSubview:background];
    
   // img = [[UIHelper getInstance] getBundleImage:@"coatimage.png"];
   // UIImageView *coatimage = [[UIImageView alloc]initWithImage:[[UIHelper getInstance] getBundleImage:@"clear.png"]];
    UIView *coatimage = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 240)];
    coatimage.userInteractionEnabled = YES;
    
    UIView *container = [[UIView alloc] initWithFrame:coatimage.bounds];
    [self.view addSubview:container];
    container.userInteractionEnabled = YES;
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        container.top = 360+64;
    }
    else
    {
        container.top = 360;
    }
        
    UIImageView *productImageV = [[UIImageView alloc] initWithFrame:CGRectMake(33, 17, 250, 240)];
    [container addSubview:productImageV];
    productImageV.userInteractionEnabled = YES;
    productImageV.clipsToBounds = YES;
    productImageV.contentMode = UIViewContentModeScaleAspectFit;
    productImageV.backgroundColor = [UIColor clearColor];
    
    UIImageView *clear = [[UIImageView alloc] initWithFrame:CGRectMake(33, 17, 250, 188)];
    [coatimage addSubview:clear];
    clear.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
    [clear addGestureRecognizer:tapGes];
    clear.clipsToBounds = YES;
    clear.contentMode = UIViewContentModeScaleAspectFill;
    clear.backgroundColor = [UIColor clearColor];
    productImage_ = productImageV;
    
        NSString *url = [NSString stringWithFormat:@"%@",obj.pThumbURL];
        nowpicUrl = obj.pURL;
        NSString * path = [[[PMGlobal getInstance] getImageURL] stringByAppendingPathComponent:url];
        path = [path stringByReplacingOccurrencesOfString:@"http:/" withString:@"http://"];
        
        if ([[PMGlobal getInstance]isImageEnable]) {
            productImage_.image = [imageCache_ imageForKey:obj.pThumbURL url:[NSURL URLWithString:path] queueIfNeeded:YES tag:0];
            if (!productImage_.image) {
                productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
            }
        }else{
            productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
        }

    UIView *collectback = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 45)];
        collectback.backgroundColor = [UIColor colorWithRed:177/255.0 green:177/255.0 blue:177/255.0 alpha:0.55];
    collectback.right = productImageV.right;
    collectback.bottom = productImageV.bottom;
    [coatimage addSubview:collectback];
    
    UIImage *img2 = [[UIHelper getInstance] getBundleImage:@"collect_image.png"];
    for (int i = 0; i<5; i++) {
        UIButton *collect = [UIButton buttonWithType:UIButtonTypeCustom];
        if (i<[[DataManager sharedManager]productIsFavorite:obj Shopid:numshopid]) {
            [collect setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_redimage.png"] forState:UIControlStateNormal];
        }
        else
        {
            [collect setBackgroundImage:img2 forState:UIControlStateNormal];
        }
            collect.frame = CGRectMake(i*40+62, 0, img2.size.width, img2.size.height);
            collect.tag = i+10000;
           // collect.right = productImageV.right-5;
            collect.bottom = productImageV.bottom-7;
            [collect addTarget:self action:@selector(collect:) forControlEvents:UIControlEventTouchUpInside];
            [coatimage addSubview:collect];
    }
    
    collectback.userInteractionEnabled = YES;
    
    coatimage.frame = CGRectMake(0, 0, 250, 240);
    [container addSubview:coatimage];
    
   // img = [[UIHelper getInstance] getBundleImage:@"detail_coatimagebar.png"];
   // UIImageView *imagebar = [[UIImageView alloc]initWithImage:img];
   // imagebar.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        UIView *imagebar = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 33)];
        imagebar.backgroundColor = [UIColor colorWithRed:177/255.0 green:177/255.0 blue:177/255.0 alpha:1];
    imagebar.center = CGPointMake(coatimage.width/2+33, 285);
    [coatimage addSubview:imagebar];
        
        img = [UIImage imageNamed:@"price.png"];
        UIImageView *price = [[UIImageView alloc]initWithImage:img];
        price.frame = CGRectMake(20, 265, img.size.width, img.size.height);
        [coatimage addSubview:price];
    
    sale = [[UILabel alloc]initWithFrame:CGRectMake(60, 269, 100, 30)];
    sale.backgroundColor = [UIColor clearColor];
    sale.textColor = [UIColor colorWithRed:57/255.0 green:14/255.0 blue:0 alpha:1.0];
    sale.textAlignment = UITextAlignmentLeft;
    NSString *salestr = [NSString stringWithFormat:@"%.0f元",obj.pSale];
    sale.text = salestr;
    [coatimage addSubview:sale];
    
    code1 = [[UILabel alloc]initWithFrame:CGRectMake(180, 269, 100, 30)];
    code1.backgroundColor = [UIColor clearColor];
    code1.textColor = [UIColor colorWithRed:57/255.0 green:14/255.0 blue:0 alpha:1.0];
    code1.text = obj.pCode;
        code1.adjustsFontSizeToFitWidth=YES;
    code1.textAlignment = NSTextAlignmentCenter;
    code1.centerX = 190;
    [coatimage addSubview:code1];
    
    detail = [[UIImageView alloc]initWithImage:[[UIHelper getInstance] getBundleImage:@"clear.png"]];
   // img = [[UIHelper getInstance] getBundleImage:@"detail.png"];
    if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7.0)
    {
        detail.frame = CGRectMake(0, 360+64, 360, 343);
    }
    else
    {
        detail.frame = CGRectMake(0, 360, 360, 343);
    }
    detail.userInteractionEnabled = YES;
    detail.left = coatimage.right + 80;
    detailleftnum = detail.left;
    [self.view addSubview:detail];
    
    UILabel *titlecell = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 120, 50)];
    titlecell.backgroundColor = [UIColor clearColor];
    titlecell.center = CGPointMake(85, 30+20);
    titlecell.text = @"商品详情";
        titlecell.font = [UIFont systemFontOfSize:30];
    titlecell.textColor = [UIColor colorWithRed:57/255.0 green:14/255.0 blue:0 alpha:1.0];
    titlecell.textAlignment = NSTextAlignmentCenter;
    [detail addSubview:titlecell];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, detail.width, 1)];
        line.top = titlecell.bottom;
        line.backgroundColor = [UIColor blackColor];
        [detail addSubview:line];
    /*
    img = [[UIHelper getInstance] getBundleImage:@"detail_titleline.png"];
    UIImageView *titleline = [[UIImageView alloc]initWithImage:img];
    titleline.frame = CGRectMake(0, 0, detail.width, img.size.height);
    titleline.center = CGPointMake(detail.width/2, 34);
    [detail addSubview:titleline];
    */
    UIScrollView *detailscroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 35, detail.width, detail.height-90)];
        detailscroll.top = line.bottom;
    detailscroll.backgroundColor = [UIColor clearColor];
    detailscroll.clipsToBounds = YES;
    [detail addSubview:detailscroll];
    
    int bottom=0;
    NSArray *array = [[DataManager sharedManager]getSpdmOrder];
    for (int i = 0; i<array.count; i++) {
        NSDictionary *dic = [array objectAtIndex:i];
        NSString *titlename = [dic objectForKey:@"c_spdmmc"];
        NSString *name = [dic objectForKey:@"c_spdmzd"];
        NSString *isvisible = [dic objectForKey:@"b_visible"];
        if ([isvisible isEqualToString:@"0"]) {
            continue;
        }
        
        //NSString *content = [[DataManager sharedManager]getspdmorder:obj titlename:name];
        NSString *content = [obj getValueByKey:name];

        str = [NSString stringWithFormat:@"%@：%@",titlename,content];
        if ([content isEqualToString:@""]) {
            continue;
        }
        CGSize s = [str sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(detail.width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
        DetailcellView *cell = [[DetailcellView alloc]initWithFrame:CGRectMake(0, 0, detail.width, s.height+1)];
        cell.top=bottom;
        cell.title.text = str;
        bottom=cell.bottom;
        [detailscroll addSubview:cell];
        detailscroll.contentSize = CGSizeMake(detailscroll.width, bottom);
    }
    input = [[NumberInputView alloc]initWithFrame:CGRectMake(self.view.height-320, 360, 260, 290)];
    input.top = background.top+5+20;
#ifdef DHH_iOS
    input.left = detail.right+2;
    
#else
    input.left = detail.right+2+30;
#endif

    input.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1.0];
    input.delegate = self;
    [self.view addSubview:input];
    

#ifdef XLarge_ENABLE
    //如果有加大码则加载加大码视图
    if (bigobj) {
        bigView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 1024, 230)];
        bigView.userInteractionEnabled = YES;
        bigView.bounces = NO;
        [self.view addSubview:bigView];
        
        [self addBigObj:(NSString *)shopid shopname:(NSString *)shopname];
        
        view.height = 120;
        bigView.height = 120;
        
        bigView.top = view.bottom+5;
    }

    
    //如果有加裤则显示加裤标签，加裤没有加大码之分
//    jkobj = [[DataManager sharedManager] getProductObjectByName:[product.pCode stringByAppendingString:@"JK"] andColor:product.pColorCode];
    
    if (jkobj) {
        UIButton *typejkbtn = [UIButton buttonWithType:UIButtonTypeCustom];
        typejkbtn.frame = CGRectMake(0, 0, 80, 25);
        [typejkbtn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"anniu.png"] forState:UIControlStateNormal];
        [typejkbtn setTitle:@"加裤" forState:UIControlStateNormal];
        typejkbtn.origin = CGPointMake(sizeType.count*85+20, 0);
        [typejkbtn addTarget:self action:@selector(selectSizeType:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:typejkbtn];
        typejkbtn.top = tint.bottom+5;
        typejkbtn.tag = 1200;
        
        jkView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 1024, 230)];
        jkView.userInteractionEnabled = YES;
        jkView.bounces=NO;
        [self.view addSubview:jkView];
        
        [self addJKObj:(NSString *)shopid shopname:(NSString *)shopname];
        
        jkView.top = view.top;
        
    
        [jkView setHidden:YES];

    }
        #endif
    }

    [self refreshisordering];
}

-(void)clearOrder:(UIButton *)sender{
    ismodify=YES;
    isclear1=YES;
    int num = sender.tag;
    
    NSLog(@"%d",sizetabindex);
    
    if (sender.tag>=186000) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"该款为取消款" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        return;
    }
    if (num==20000) {
        [order clearOrder];
        for (int i = 0; i<sizegroupid.count; i++) {
            
            UITextField* txt = (UITextField*)[view viewWithTag:i+10];
            
            totalnum = totalnum - [txt.text intValue];

            txt.text = @"0";
            
        }
        
        UITextField* txt = (UITextField*)[view viewWithTag:110000];
        txt.text = @"0";
        
    }
    else if(num>=21000&&num<22000)
    {
        int tag = num -21000;
        OrderObject *simorder = [orders objectAtIndex:tag];
        [simorder clearOrder];
        for (int i = 0; i<sizegroupid.count; i++) {
            
            UITextField* txt = (UITextField*)[view viewWithTag:(tag+1)*100+i];
            totalnum = totalnum - [txt.text intValue];
            
            txt.text = @"0";
            
        }
        UITextField* txt = (UITextField*)[view viewWithTag:110001+tag];
        txt.text = @"0";
        
    }
    
    else if(num ==22000)
    {
        [bigorder clearOrder];
        for (int i = 0; i<sizegroupid.count; i++) {
            
            UITextField* txt = (UITextField*)[bigView viewWithTag:140000+i+10];
            totalnum = totalnum - [txt.text intValue];
            txt.text = @"0";
            
        }
        UITextField* txt = (UITextField*)[bigView viewWithTag:120000];
        txt.text = @"0";
        
        
    }
    else if(num>=23000 && num <24000)
    {
        int tag = num -23000;
        OrderObject *simorder = [bigorders objectAtIndex:tag];
        [simorder clearOrder];
        for (int i = 0; i<sizegroupid.count; i++) {
            
            UITextField* txt = (UITextField*)[bigView viewWithTag:140000+i+100*(tag+1)];
            totalnum = totalnum - [txt.text intValue];
            txt.text = @"0";
            
        }
        UITextField* txt = (UITextField*)[bigView viewWithTag:120001+tag];
        txt.text = @"0";
        
    }
    
    else if(num >=24000&& num<25000)
    {
        [jkorder clearOrder];
        for (int i = 0; i<jksizegroupid.count; i++) {
            
            UITextField* txt = (UITextField*)[jkView viewWithTag:150000+i+10];
            totalnum = totalnum - [txt.text intValue];
            txt.text = @"0";
            
        }
        UITextField* txt = (UITextField*)[jkView viewWithTag:130000];
        txt.text = @"0";
        
        
    }
    
    else{
        
        int tag = num -25000;
        OrderObject *simorder = [jkorders objectAtIndex:tag];
        [simorder clearOrder];
        for (int i = 0; i<jksizegroupid.count; i++) {
            
            UITextField* txt = (UITextField*)[jkView viewWithTag:150000+i+100*(tag+1)];
            totalnum = totalnum - [txt.text intValue];
            txt.text = @"0";
            
        }
        UITextField* txt = (UITextField*)[jkView viewWithTag:130001+tag];
        txt.text = @"0";
        
        
    }

    
    [self refreshTotalQuantityLabel];
    
    [edittext resignFirstResponder];
}


-(void)selectSizeType:(UIButton *)sender
{
    [self textFieldDidEndEditing:edittext];
    countnumber = 0;
    similarcountnumber = 0;
    sizetabindex = sender.tag-1100;
    text = nil;
    if (sizetabindex==100) {
        //加裤
        
        [bigView setHidden:YES];
        [view setHidden:YES];
        [jkView setHidden:NO];
        
        view.height = 230;
        
    }
    else{
        //其它版型
        [sizegroupid removeAllObjects];
        totalsizegroupid = [[DataManager sharedManager] getSizeListBySizeGroup:obj.pSizeGroupID SizeType:[sizeType objectAtIndex:sizetabindex]];
        NSArray *sizestatues = [[DataManager sharedManager]issizecancel:obj.pCode colorid:obj.pColorCode];
        for (int i=0;i<totalsizegroupid.count;i++) {
            SizeObject *sizeobj = [totalsizegroupid objectAtIndex:i];
            
            BOOL isValid = NO;
            for (int j = 0; j < sizestatues.count; j++) {
                NSString *size = [sizestatues objectAtIndex:j];
                if ([size intValue] == [sizeobj.sSizeNo intValue]) {
                    isValid = YES;
                    break;
                }
            }
            
            if (isValid) {
                [sizegroupid addObject:sizeobj];
            }
            
        }
        
        for (int i = 0; i<sizegroupid.count; i++) {
            
            SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
            UILabel *label = (UILabel*)[scroll viewWithTag:1500+i ];
            label.text = sizeobject.sSizeName;
            label = (UILabel*)[bigscroll viewWithTag:1500+i ];
            label.text = sizeobject.sSizeName;
            
            
            //切换的时候显示已经下过的订单数
            UITextField *textfield = (UITextField*) [scroll viewWithTag:10+i ];
            NSString *num = [NSString stringWithFormat:@"%d",[order getOrder:sizeobject.sSizeNo withShopID:numshopid]];
            textfield.text = num;
            
            textfield = (UITextField*) [bigscroll viewWithTag:140000+10+i ];
            num = [NSString stringWithFormat:@"%d",[bigorder getOrder:sizeobject.sSizeNo withShopID:numshopid]];
            textfield.text = num;
            
            
            
            for (int i = 0; i<similar.count; i++) {
                OrderObject *order1 = [orders objectAtIndex:i];
                
                for(int j=0;j<sizegroupid.count;j++)
                {
                    SizeObject *sizeobject = [sizegroupid objectAtIndex:j];
                    NSString * sizeno = sizeobject.sSizeNo ;
                    UITextField *textfield =(UITextField*) [scroll viewWithTag:j+100*(i+1) ];
                    NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
                    textfield.text = num;
                    
                }
            }
            
            for (int i = 0; i<bigsimilar.count; i++) {
                OrderObject *order1 = [bigorders objectAtIndex:i];
        
                for(int j=0;j<sizegroupid.count;j++)
                {
                    SizeObject *sizeobject = [sizegroupid objectAtIndex:j];
                    NSString * sizeno = sizeobject.sSizeNo ;
                    UITextField *textfield =(UITextField*) [bigscroll viewWithTag:140000+j+100*(i+1) ];
                    NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
                    textfield.text = num;

                }
            }
            
        }
        for (int i = 0; i<sizegroupid.count; i++) {
            UITextField *textfield = (UITextField*) [scroll viewWithTag:10+i ];
            countnumber+=[textfield.text intValue];
        }
        UILabel *label = (UILabel *)[view viewWithTag:110000];
        NSString *num = [NSString stringWithFormat:@"%d",countnumber];
        label.text = num;
        for (int i = 0; i<similar.count; i++) {
            similarcountnumber = 0;
            for(int j=0;j<sizegroupid.count;j++)
            {
                UITextField *textfield = (UITextField*) [scroll viewWithTag:j+100*(i+1) ];
                similarcountnumber+=[textfield.text intValue];
            }
            UILabel *label = (UILabel *)[view viewWithTag:110001+i];
            NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
            label.text = num;
        }
        countnumber = 0;
        for (int i = 0; i<sizegroupid.count; i++) {
            UITextField *textfield = (UITextField*) [bigscroll viewWithTag:140000+10+i ];
            countnumber+=[textfield.text intValue];
        }
        UILabel *label1 = (UILabel *)[bigView viewWithTag:120000];
        NSString *num1 = [NSString stringWithFormat:@"%d",countnumber];
        label1.text = num1;
        for (int i = 0; i<similar.count; i++) {
            similarcountnumber = 0;
            for(int j=0;j<sizegroupid.count;j++)
            {
                UITextField *textfield = (UITextField*) [bigscroll viewWithTag:140000+j+100*(i+1) ];
                similarcountnumber+=[textfield.text intValue];
            }
            UILabel *label = (UILabel *)[bigView viewWithTag:120001+i];
            NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
            label.text = num;
        }
        
#ifdef XLarge_ENABLE
        [bigView setHidden:NO];
        [view setHidden:NO];
        if (bigobj) {
            view.height = 120;
            bigView.height =120;
            bigView.top = view.bottom+5;
        }
        
        [jkView setHidden:YES];
#endif
        
    }
    
}
#ifdef XLarge_ENABLE
-(void)addBigObj:(NSString *)shopid shopname:(NSString *)shopname{
    //大码订单信息
    countnumber = 0;
    similarcountnumber = 0;
        bigsimilar = [[DataManager sharedManager] getSimiliarProduct:bigobj];
    
        bigscroll = [[UIScrollView alloc]initWithFrame:CGRectMake(172, 0, 630, bigView.height+200)];
        bigscroll.alwaysBounceVertical = NO;
        bigscroll.alwaysBounceHorizontal = YES;
        bigscroll.showsHorizontalScrollIndicator = NO;
        bigscroll.bounces = NO;
        [bigView addSubview:bigscroll];
        for (int i = 0; i<sizegroupid.count; i++) {
        
            SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
            if (sizegroupid.count<10) {
                width = bigscroll.width/sizegroupid.count;
            }
            else
            {
                width = 70;
            }
        
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(width*i+1, 0, width-1, 35)];
            label.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
            label.text = sizeobject.sSizeName;
            label.textColor = [UIColor whiteColor];
            label.tag = 1500+i;
            label.textAlignment = NSTextAlignmentCenter;
            [bigscroll addSubview:label];
            
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(width*(i+1), 0, 1, 70)];
            line.backgroundColor = [UIColor blackColor];
            [bigscroll addSubview:line];
            
            bigscroll.contentSize = CGSizeMake(width*(i+1), 70);
        }
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 70)];
        line1.backgroundColor = [UIColor blackColor];
        [bigView addSubview:line1];
    
        UIView *report = [[UIView alloc]initWithFrame:CGRectMake(20, 0, 152, 35)];
        report.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
        [bigView addSubview:report];
        
        UIView *reportline1 = [[UIView alloc]initWithFrame:CGRectMake(20, 0, 152, 35)];
        reportline1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        reportline1.top = report.bottom;
        [bigView addSubview:reportline1];
        

    
        UILabel *reportline2 = [[UILabel alloc]initWithFrame:CGRectMake(20, 354, 980, 20)];
        reportline2.backgroundColor = [UIColor colorWithRed:209/255.0 green:194/255.0 blue:176/255.0 alpha:1];
        reportline2.text = @"同款其它";
        reportline2.textAlignment = UITextAlignmentCenter;
        reportline2.textColor = [UIColor whiteColor];
    
        reportline2.top = reportline1.bottom;
        [bigView addSubview:reportline2];
    
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(95, 0, 1, 70)];
        line.backgroundColor = [UIColor blackColor];
        [bigView addSubview:line];
    line.hidden = YES;
        
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(172, 0, 1, 70)];
        line2.backgroundColor = [UIColor blackColor];
        [bigView addSubview:line2];
    
    
    UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(803, 0, 199, 35)];
    report1.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    [bigView addSubview:report1];
    
    UIView *reportline11 = [[UIView alloc]initWithFrame:CGRectMake(803, 0, 199, 35)];
    reportline11.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline11.top = report1.bottom;
    [bigView addSubview:reportline11];

    UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(812, 0, 77, 35)];
    count.backgroundColor = [UIColor clearColor];
    count.text = @"小计";
    count.textColor = [UIColor whiteColor];
    count.textAlignment = NSTextAlignmentCenter;
    [bigView addSubview:count];
    
    UILabel *operate = [[UILabel alloc]initWithFrame:CGRectMake(892, 0, 77, 35)];
    operate.backgroundColor = [UIColor clearColor];
    operate.text = @"操作";
    operate.textColor = [UIColor whiteColor];
    operate.textAlignment = NSTextAlignmentCenter;
    [bigView addSubview:operate];
        
        UILabel *bigcode = [[UILabel alloc]initWithFrame:CGRectMake(20, 35, 150, 35)];
        bigcode.backgroundColor = [UIColor clearColor];
        NSString * str = [NSString stringWithFormat:@"%@",bigobj.pColor];
        bigcode.text = str;
        bigcode.textAlignment = NSTextAlignmentCenter;
        [bigView addSubview:bigcode];
        
//        UILabel *bigcolor1 = [[UILabel alloc]initWithFrame:CGRectMake(95, 35, 75, 35)];
//        bigcolor1.backgroundColor = [UIColor clearColor];
//        bigcolor1.text = bigobj.pColor;
//        bigcolor1.textAlignment = NSTextAlignmentCenter;
//        [bigView addSubview:bigcolor1];
    
        UIView* dummyView = [[UIView alloc] initWithFrame:CGRectZero];
        
        reportline2.top = bigcode.bottom;
        
        UIView* bigdummyView = [[UIView alloc] initWithFrame:CGRectZero];
        for(int i=0;i<sizegroupid.count;i++)
        {
            SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
            UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(1+ width*i, 35, width-1, 35)];
            textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            textfield.delegate = self;
            NSString *num = [NSString stringWithFormat:@"%d",[bigorder getOrder:sizeobject.sSizeNo withShopID:numshopid]];
            textfield.text = num;
            textfield.tag = 140000+i+10;
            textfield.inputView = bigdummyView;
            textfield.textAlignment = NSTextAlignmentCenter;
            textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [bigscroll addSubview:textfield];
            countnumber += [bigorder getOrder:sizeobject.sSizeNo withShopID:numshopid];
        }
        UILabel *countnum = [[UILabel alloc]initWithFrame:CGRectMake(812, 35, 77, 35)];
        countnum.backgroundColor = [UIColor clearColor];
        NSString *number = [NSString stringWithFormat:@"%d",countnumber];
        countnum.text = number;
        countnum.tag = 120000;
        countnum.textAlignment = NSTextAlignmentCenter;
        [bigView addSubview:countnum];
    [bigcountarr addObject:countnum.text];
    
        if (numtag==0) {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(875, 40, 50, 25);
            match.tag = 20000;
            [match setTitle:@"搭配" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
            [bigView addSubview:match];
            
            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(930, 40, 50, 25);
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            proportion.tag =22000;
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            
            [bigView addSubview:proportion];
        }
        else
        {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
#if ENABLE_RATIO
            
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(875, 40, 50, 25);
            match.tag = 20000;
            [match setTitle:@"配比" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
            [bigView addSubview:match];
#else
#endif

            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(930, 40, 50, 25);
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            proportion.tag =22000;
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            [bigView addSubview:proportion];
        }
    
    
        //同款不同色
        for (int i = 0; i<bigsimilar.count; i++) {
            ProductObject *product = [bigsimilar objectAtIndex:i];
            OrderObject *orderobj = [[DataManager sharedManager]createOrderByProduct:product ShopId:shopid];
            [bigorders addObject:orderobj];
            OrderObject *order1 = [bigorders objectAtIndex:i];
            
            UIView *report = [[UIView alloc]initWithFrame:CGRectMake(20, 35*i+reportline2.bottom, 152, 35)];
            report.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            [bigView addSubview:report];
            
            UIView *line11 = [[UIView alloc]initWithFrame:CGRectMake(95, 0, 1, 35)];
            line11.backgroundColor = [UIColor blackColor];
            line11.top = report.top;
            line11.hidden = YES;
            [bigView addSubview:line11];
            
            UIView *line12 = [[UIView alloc]initWithFrame:CGRectMake(172, 0, 1, 35)];
            line12.backgroundColor = [UIColor blackColor];
            line12.top = report.top;
            [bigView addSubview:line12];
            
            UILabel *code = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 150, 35)];
            code.backgroundColor = [UIColor clearColor];
            NSString *str = [NSString stringWithFormat:@"%@",product.pColor];
            
            code.text = str;
            code.textAlignment = NSTextAlignmentCenter;
            code.top = report.top;
            [bigView addSubview:code];
            
//            UILabel *color1 = [[UILabel alloc]initWithFrame:CGRectMake(95, 35, 75, 35)];
//            color1.backgroundColor = [UIColor clearColor];
//            color1.text = product.pColor;
//            color1.top = report.top;
//            color1.textAlignment = NSTextAlignmentCenter;
//            [bigView addSubview:color1];
            
            for(int j=0;j<sizegroupid.count;j++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:j];
                NSString * sizeno = sizeobject.sSizeNo ;
                UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(1 + width*j, 0, width-1, 35)];
                textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
                textfield.delegate = self;
                NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
                textfield.text = num;
                textfield.tag = 140000+j+100*(i+1);
                textfield.top = report.top;
                textfield.inputView = dummyView;
                textfield.textAlignment = NSTextAlignmentCenter;
                textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [bigscroll addSubview:textfield];
                similarcountnumber += [order1 getOrder:sizeno withShopID:numshopid];
            }
            bigscroll.contentSize = CGSizeMake(bigscroll.contentSize.width, 95+(i*35));
            for (int j = 0; j<sizegroupid.count; j++) {
                UIView *line = [[UIView alloc]initWithFrame:CGRectMake(width*(j+1), 0, 1, 35)];
                line.backgroundColor = [UIColor blackColor];
                line.top = report.top;
                [bigscroll addSubview:line];
                
            }
            UIView *scrollline = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 35)];
            scrollline.backgroundColor = [UIColor blackColor];
            scrollline.top = report.top;
            [bigView addSubview:scrollline];
            
            UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, line1.bottom, width*(sizegroupid.count), 1)];
            scrollline1.backgroundColor = [UIColor blackColor];
            scrollline1.top = report.bottom-1;
            [bigscroll addSubview:scrollline1];
            
            UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 35)];
            line1.backgroundColor = [UIColor blackColor];
            line1.top = report.top;
            [bigView addSubview:line1];
            
            UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(20, line1.bottom, 152, 1)];
            line2.backgroundColor = [UIColor blackColor];
            line2.top = report.bottom-1;
            [bigView addSubview:line2];
            
            UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(803, 90+i*35, 199, 35)];
            report1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            [bigView addSubview:report1];
            
            UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(803, line1.bottom, 199, 1)];
            line3.backgroundColor = [UIColor blackColor];
            line3.top = report1.bottom-1;
            [bigView addSubview:line3];
            
            UILabel *countnumone = [[UILabel alloc]initWithFrame:CGRectMake(812, 90+i*35, 77, 35)];
            countnumone.backgroundColor = [UIColor clearColor];
            NSString *number = [NSString stringWithFormat:@"%d",similarcountnumber];
            countnumone.text = number;
            countnumone.tag = 120001+i;
            countnumone.textAlignment = NSTextAlignmentCenter;
            [bigView addSubview:countnumone];
            [bigcountarr addObject:countnumone.text];
            
            if (numtag==0) {
                UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
                UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
                [match setBackgroundImage:img3 forState:UIControlStateNormal];
                match.frame = CGRectMake(875, 95+35*i, 50, 25);
                match.tag = 100001+i;
                [match setTitle:@"搭配" forState:UIControlStateNormal];
                [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
                [bigView addSubview:match];
                

                UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
                [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
                proportion.frame = CGRectMake(930, 95+35*i, 50, 25);
                [proportion setTitle:@"清除" forState:UIControlStateNormal];
                proportion.tag = 23000+i;
                [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
                
                [bigView addSubview:proportion];
            }
            else
            {
                UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
#if ENABLE_RATIO
                
                UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
                [match setBackgroundImage:img3 forState:UIControlStateNormal];
                match.frame = CGRectMake(875, 95+35*i, 50, 25);
                match.tag = 20001+i;
                [match setTitle:@"配比" forState:UIControlStateNormal];
                [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
                [bigView addSubview:match];
#else
#endif

                UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
                [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
                proportion.frame = CGRectMake(930, 95+35*i, 50, 25);
                [proportion setTitle:@"清除" forState:UIControlStateNormal];
                proportion.tag = 23000+i;
                [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
                
                [bigView addSubview:proportion];
            }
            
            bigView.contentSize = CGSizeMake(bigView.width, bigscroll.contentSize.height+80);
            
        }
    
}

-(void)addJKObj:(NSString *)shopid shopname:(NSString *)shopname{
    /*
#ifdef DHH_iOS
    countnumber = 0;
    similarcountnumber = 0;
    jksizegroupid = [[DataManager sharedManager] getSizeListBySizeGroup:jkobj.pSizeGroupID SizeType:@""];
    jksimilar = [[DataManager sharedManager] getSimiliarProduct:jkobj];
    
    jkView = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 0, 300, 400)];
    jkView.userInteractionEnabled = YES;
    jkView.top = tint.bottom-10;
    [scrollview addSubview:jkView];
    
    UIView *report = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 35)];
    report.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    report.tag = 180001;
    [jkView addSubview:report];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap2:)];
    [report addGestureRecognizer:tap];
    
    UILabel *code = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 35)];
    code.backgroundColor = [UIColor clearColor];
    NSString *str = [NSString stringWithFormat:@"%@-%@",jkobj.pColorCode,jkobj.pColor];
    code.text = str;
    code.textAlignment = NSTextAlignmentCenter;
    [report addSubview:code];
    
    UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(60, 0, 60, 35)];
    count.backgroundColor = [UIColor clearColor];
    // count.left = right + 10;
    count.text = @"小计";
    count.textColor = [UIColor whiteColor];
    count.textAlignment = NSTextAlignmentCenter;
    [report addSubview:count];
    
    iphonescroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 35, 300, 71)];
    [jkView addSubview:iphonescroll];
    
    for (int i = 0; i<jksizegroupid.count; i++) {
        
        SizeObject *sizeobject = [jksizegroupid objectAtIndex:i];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(77*i, 0, 76, 35)];
        label.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        label.text = sizeobject.sSizeName;
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.userInteractionEnabled = YES;
        [iphonescroll addSubview:label];
        
        UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap3:)];
        [label addGestureRecognizer:tap3];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(77*(i+1)-1, 0, 1, 71)];
        line.backgroundColor = [UIColor blackColor];
        [iphonescroll addSubview:line];
        
        iphonescroll.contentSize = CGSizeMake(77*(i+1), 71);
        right = 152 + 77*(i+1);
    }
    
    UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, 35, 77*(jksizegroupid.count), 1)];
    scrollline1.backgroundColor = [UIColor blackColor];
    //   scrollline1.top = report.bottom-1;
    [iphonescroll addSubview:scrollline1];

    NumberInputView *input = [[NumberInputView alloc]initWithFrame:CGRectMake(0, 60, 320, 220)];
    input.backgroundColor = [UIColor colorWithRed:255/255.0 green:251/255.0 blue:236/255.0 alpha:1.0];
    input.delegate = self;
    input.top = self.view.bottom;
    input.tag = 180002;
    [self.view addSubview:input];
    //  UIView* dummyView = [[UIView alloc] initWithFrame:CGRectZero];
    for(int i=0;i<jksizegroupid.count;i++)
    {
        SizeObject *sizeobject = [jksizegroupid objectAtIndex:i];
        NSString * sizeno = sizeobject.sSizeNo;
        UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(77*i, 36, 76, 35)];
        textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        textfield.delegate = self;
        NSString *num = [NSString stringWithFormat:@"%d",[order getOrder:sizeno withShopID:numshopid]];
        textfield.text = num;
        textfield.tag = i+10;
        textfield.inputView = input;
        textfield.textAlignment = NSTextAlignmentCenter;
        textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [iphonescroll addSubview:textfield];
        countnumber += [order getOrder:sizeno withShopID:numshopid];
    }
    
    UILabel *countnum = [[UILabel alloc]initWithFrame:CGRectMake(120, 0, 60, 35)];
    countnum.backgroundColor = [UIColor clearColor];
    //  countnum.left = right + 10;
    countnum.tag = 110000;
    NSString *number = [NSString stringWithFormat:@"%d",countnumber];
    countnum.text = number;
    countnum.textColor = [UIColor blackColor];
    countnum.textAlignment = NSTextAlignmentCenter;
    [report addSubview:countnum];
    
    UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
    UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
    [match setBackgroundImage:img3 forState:UIControlStateNormal];
    match.frame = CGRectMake(180, 0, 50, 25);
    // match.left = right + 70;
    match.centerY = report.height/2;
    [match setTitle:@"配比" forState:UIControlStateNormal];
    [report addSubview:match];
    
    
    UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
    [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
    proportion.frame = CGRectMake(240, 0, 50, 25);
    proportion.centerY = report.height/2;
    [proportion setTitle:@"清除" forState:UIControlStateNormal];
    [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
    
    // proportion.left = match.right + 10;
    // [proportion setTitle:@"配比" forState:UIControlStateNormal];
    [report addSubview:proportion];
    
    UIView *reportline2 = [[UIView alloc]initWithFrame:CGRectMake(0, 105, 300, 20)];
    reportline2.backgroundColor = [UIColor colorWithRed:57/255.0 green:14/255.0 blue:0 alpha:1];
    reportline2.tag = 180000;
    // reportline2.width = right + 200;
    [jkView addSubview:reportline2];
    
    for (int i = 0; i<jksimilar.count; i++) {
        ProductObject *product = [jksimilar objectAtIndex:i];
        OrderObject *orderobj = [[DataManager sharedManager]createOrderByProduct:product ShopId:numshopid ];
        [orders addObject:orderobj];
        OrderObject *order1 = [orders objectAtIndex:i];
        
        UIView *report = [[UIView alloc]initWithFrame:CGRectMake(0, 126+36*i, 300, 36)];
        report.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        report.tag = 160001+i;
        [jkView addSubview:report];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap1:)];
        [report addGestureRecognizer:tap];
        
        UILabel *code = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 35)];
        code.backgroundColor = [UIColor clearColor];
        NSString *str = [NSString stringWithFormat:@"%@-%@",product.pColorCode,product.pColor];
        code.text = str;
        code.textAlignment = NSTextAlignmentCenter;
        [report addSubview:code];
        
        UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(60, 0, 60, 35)];
        count.backgroundColor = [UIColor clearColor];
        // count.left = right + 10;
        count.text = @"小计";
        count.textColor = [UIColor blackColor];
        count.textAlignment = NSTextAlignmentCenter;
        [report addSubview:count];
        
        UIScrollView *similarscroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 300, 71)];
        similarscroll.bottom = report.bottom;
        similarscroll.tag = 170001+i;
        similarscroll.hidden = YES;
        [jkView addSubview:similarscroll];
        
        for (int i = 0; i<jksizegroupid.count; i++) {
            
            SizeObject *sizeobject = [jksizegroupid objectAtIndex:i];
            
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(77*i, 0, 76, 35)];
            label.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            label.text = sizeobject.sSizeName;
            label.textColor = [UIColor blackColor];
            label.textAlignment = NSTextAlignmentCenter;
            label.userInteractionEnabled = YES;
            [similarscroll addSubview:label];
            
            UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap3:)];
            [label addGestureRecognizer:tap3];
            
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(77*(i+1)-1, 0, 1, 71)];
            line.backgroundColor = [UIColor blackColor];
            [similarscroll addSubview:line];
            
            similarscroll.contentSize = CGSizeMake(77*(i+1), 71);
            right = 152 + 77*(i+1);
        }
        //尺码和数据中间那条线
        UIView *scrollline2 = [[UIView alloc]initWithFrame:CGRectMake(0, 35, 77*(jksizegroupid.count), 1)];
        scrollline2.backgroundColor = [UIColor blackColor];
        //   scrollline1.top = report.bottom-1;
        [similarscroll addSubview:scrollline2];
        
        for(int j=0;j<jksizegroupid.count;j++)
        {
            SizeObject *sizeobject = [jksizegroupid objectAtIndex:j];
            NSString * sizeno = sizeobject.sSizeNo ;
            UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(77*j, 36, 76, 35)];
            textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            textfield.delegate = self;
            NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
            textfield.text = num;
            textfield.tag = j+100*(i+1);
            textfield.inputView = input;
            textfield.textAlignment = NSTextAlignmentCenter;
            textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [similarscroll addSubview:textfield];
            similarcountnumber += [order1 getOrder:sizeno withShopID:numshopid];
        }

        UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, 35, 77*(jksizegroupid.count), 1)];
        scrollline1.backgroundColor = [UIColor blackColor];
        [report addSubview:scrollline1];
        
        UILabel *countnumone = [[UILabel alloc]initWithFrame:CGRectMake(120, 0, 60, 35)];
        countnumone.backgroundColor = [UIColor clearColor];
        //  countnumone.left = right + 10;
        countnumone.tag = 110001+i;
        NSString *number = [NSString stringWithFormat:@"%d",similarcountnumber];
        countnumone.text = number;
        countnumone.textAlignment = NSTextAlignmentCenter;
        [report addSubview:countnumone];
        
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(180, 95+35*i, 50, 25);
        match.centerY = report.height/2;
        match.tag = 100001+i;
        [match setTitle:@"配比" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
        [report addSubview:match];
        
        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(240, 95+35*i, 50, 25);
        proportion.centerY = report.height/2;
        //  proportion.left = right + 110;
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        //  [proportion setTitle:@"配比" forState:UIControlStateNormal];
        [report addSubview:proportion];
        scrollview.contentSize = CGSizeMake(self.view.width, 141 + 35*(i+1));
    }
#else
     */
    //加裤订单信息
    countnumber = 0;
    similarcountnumber = 0;
    jksizegroupid = [[DataManager sharedManager] getSizeListBySizeGroup:jkobj.pSizeGroupID SizeType:@""];
    jksimilar = [[DataManager sharedManager] getSimiliarProduct:jkobj];
    
    jkscroll = [[UIScrollView alloc]initWithFrame:CGRectMake(172, 0, 630, jkscroll.height+200)];
    jkscroll.alwaysBounceVertical = NO;
    jkscroll.alwaysBounceHorizontal = YES;
    jkscroll.showsHorizontalScrollIndicator = NO;
    jkscroll.bounces = NO;
    [jkView addSubview:jkscroll];
    for (int i = 0; i<jksizegroupid.count; i++) {
        
        SizeObject *sizeobject = [jksizegroupid objectAtIndex:i];
        if (jksizegroupid.count<10) {
            width = jkscroll.width/jksizegroupid.count;
        }
        else
        {
            width = 70;
        }
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(width*i+1, 0, width-1, 35)];
        label.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
        label.text = sizeobject.sSizeName;
        label.tag = 1500+i;
        label.textColor = [UIColor whiteColor];
        label.textAlignment = NSTextAlignmentCenter;
        [jkscroll addSubview:label];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(width*(i+1), 0, 1, 70)];
        line.backgroundColor = [UIColor blackColor];
        [jkscroll addSubview:line];
        
        jkscroll.contentSize = CGSizeMake(width*(i+1), 70);
    }
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 70)];
    line1.backgroundColor = [UIColor blackColor];
    [jkView addSubview:line1];
    
    UIView *report = [[UIView alloc]initWithFrame:CGRectMake(20, 0, 152, 35)];
    report.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    [jkView addSubview:report];
    
    UIView *reportline1 = [[UIView alloc]initWithFrame:CGRectMake(20, 0, 152, 35)];
    reportline1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline1.top = report.bottom;
    [jkView addSubview:reportline1];
    

    
    UILabel *reportline2 = [[UILabel alloc]initWithFrame:CGRectMake(20, 354, 980, 20)];
    reportline2.backgroundColor = [UIColor colorWithRed:209/255.0 green:194/255.0 blue:176/255.0 alpha:1];
    reportline2.text = @"同款其它";
    reportline2.textAlignment = UITextAlignmentCenter;
    reportline2.textColor = [UIColor whiteColor];

    reportline2.top = reportline1.bottom;
    [jkView addSubview:reportline2];
    
    
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(95, 0, 1, 70)];
    line.backgroundColor = [UIColor blackColor];
    [jkView addSubview:line];
    
    UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(172, 0, 1, 70)];
    line2.backgroundColor = [UIColor blackColor];
    [jkView addSubview:line2];
    
    
    UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(803, 0, 199, 35)];
    report1.backgroundColor = [UIColor colorWithRed:180/255.0 green:145/255.0 blue:106/255.0 alpha:1];
    [jkView addSubview:report1];
    
    UIView *reportline11 = [[UIView alloc]initWithFrame:CGRectMake(803, 0, 199, 35)];
    reportline11.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
    reportline11.top = report1.bottom;
    [jkView addSubview:reportline11];
    
    UILabel *count = [[UILabel alloc]initWithFrame:CGRectMake(812, 0, 77, 35)];
    count.backgroundColor = [UIColor clearColor];
    count.text = @"小计";
    count.textColor = [UIColor whiteColor];
    count.textAlignment = NSTextAlignmentCenter;
    [jkView addSubview:count];
    
    UILabel *operate = [[UILabel alloc]initWithFrame:CGRectMake(892, 0, 77, 35)];
    operate.backgroundColor = [UIColor clearColor];
    operate.text = @"操作";
    operate.textColor = [UIColor whiteColor];
    operate.textAlignment = NSTextAlignmentCenter;
    [jkView addSubview:operate];
    
    UILabel *bigcode = [[UILabel alloc]initWithFrame:CGRectMake(20, 35, 75, 35)];
    bigcode.backgroundColor = [UIColor clearColor];
    NSString * str = jkobj.pColorCode;
    bigcode.text = str;
    bigcode.textAlignment = NSTextAlignmentCenter;
    [jkView addSubview:bigcode];
    
    UILabel *bigcolor1 = [[UILabel alloc]initWithFrame:CGRectMake(95, 35, 75, 35)];
    bigcolor1.backgroundColor = [UIColor clearColor];
    bigcolor1.text = jkobj.pColor;
    bigcolor1.textAlignment = NSTextAlignmentCenter;
    [jkView addSubview:bigcolor1];
    
    UIView* dummyView = [[UIView alloc] initWithFrame:CGRectZero];
    
    reportline2.top = bigcode.bottom;
    
    UIView* bigdummyView = [[UIView alloc] initWithFrame:CGRectZero];
    for(int i=0;i<jksizegroupid.count;i++)
    {
        SizeObject *sizeobject = [jksizegroupid objectAtIndex:i];
        UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(1+ width*i, 35, width-1, 35)];
        textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        textfield.delegate = self;
        NSString *num = [NSString stringWithFormat:@"%d",[jkorder getOrder:sizeobject.sSizeNo withShopID:numshopid]];
        textfield.text = num;
        textfield.tag = 150000+i+10;
        textfield.inputView = bigdummyView;
        textfield.textAlignment = NSTextAlignmentCenter;
        textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [jkscroll addSubview:textfield];
        countnumber += [jkorder getOrder:sizeobject.sSizeNo withShopID:numshopid];
    }
    UILabel *countnum = [[UILabel alloc]initWithFrame:CGRectMake(812, 35, 77, 35)];
    countnum.backgroundColor = [UIColor clearColor];
    NSString *number = [NSString stringWithFormat:@"%d",countnumber];
    countnum.text = number;
    countnum.tag = 130000;
    countnum.textAlignment = NSTextAlignmentCenter;
    [jkView addSubview:countnum];
    [jkcountarr addObject:countnum.text];
    
    if (numtag==0) {
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(875, 40, 50, 25);
        match.tag = 20000;
        [match setTitle:@"搭配" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
        [jkView addSubview:match];
        
        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(930, 40, 50, 25);
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
        proportion.tag = 24000;
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        
        [jkView addSubview:proportion];
    }
    else
    {
        UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
#if ENABLE_RATIO
        
        UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
        [match setBackgroundImage:img3 forState:UIControlStateNormal];
        match.frame = CGRectMake(875, 40, 50, 25);
        match.tag = 30000;
        [match setTitle:@"配比" forState:UIControlStateNormal];
        [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
        [jkView addSubview:match];
#else
#endif

        UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
        [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
        proportion.frame = CGRectMake(930, 40, 50, 25);
        [proportion setTitle:@"清除" forState:UIControlStateNormal];
        proportion.tag = 24000;
        [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
        
        [jkView addSubview:proportion];
    }
    
    //同款不同色
    for (int i = 0; i<jksimilar.count; i++) {
        ProductObject *product = [jksimilar objectAtIndex:i];
        OrderObject *orderobj = [[DataManager sharedManager]createOrderByProduct:product ShopId:shopid];
        [jkorders addObject:orderobj];
        OrderObject *order1 = [jkorders objectAtIndex:i];
        
        UIView *report = [[UIView alloc]initWithFrame:CGRectMake(20, 35*i+reportline2.bottom, 152, 35)];
        report.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        [jkView addSubview:report];
        
        UIView *line11 = [[UIView alloc]initWithFrame:CGRectMake(95, 0, 1, 35)];
        line11.backgroundColor = [UIColor blackColor];
        line11.top = report.top;
        [jkView addSubview:line11];
        
        UIView *line12 = [[UIView alloc]initWithFrame:CGRectMake(172, 0, 1, 35)];
        line12.backgroundColor = [UIColor blackColor];
        line12.top = report.top;
        [jkView addSubview:line12];
        
        UILabel *code = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 75, 35)];
        code.backgroundColor = [UIColor clearColor];
        NSString *str = product.pColorCode;
        
        code.text = str;
        code.textAlignment = NSTextAlignmentCenter;
        code.top = report.top;
        [jkView addSubview:code];
        
        UILabel *color1 = [[UILabel alloc]initWithFrame:CGRectMake(95, 35, 75, 35)];
        color1.backgroundColor = [UIColor clearColor];
        color1.text = product.pColor;
        color1.top = report.top;
        color1.textAlignment = NSTextAlignmentCenter;
        [jkView addSubview:color1];
        
        for(int j=0;j<jksizegroupid.count;j++)
        {
            SizeObject *sizeobject = [jksizegroupid objectAtIndex:j];
            NSString * sizeno = sizeobject.sSizeNo ;
            UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(1 + width*j, 0, width-1, 35)];
            textfield.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
            textfield.delegate = self;
            NSString *num = [NSString stringWithFormat:@"%d",[order1 getOrder:sizeno withShopID:numshopid]];
            textfield.text = num;
            textfield.tag = 150000+j+100*(i+1);
            textfield.top = report.top;
            textfield.inputView = dummyView;
            textfield.textAlignment = NSTextAlignmentCenter;
            textfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [jkscroll addSubview:textfield];
            similarcountnumber += [order1 getOrder:sizeno withShopID:numshopid];
        }
        jkscroll.contentSize = CGSizeMake(jkscroll.contentSize.width, 95+(i*35));
        for (int j = 0; j<jksizegroupid.count; j++) {
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(width*(j+1), 0, 1, 35)];
            line.backgroundColor = [UIColor blackColor];
            line.top = report.top;
            [jkscroll addSubview:line];
            
        }
        UIView *scrollline = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 35)];
        scrollline.backgroundColor = [UIColor blackColor];
        scrollline.top = report.top;
        [jkView addSubview:scrollline];
        
        UIView *scrollline1 = [[UIView alloc]initWithFrame:CGRectMake(0, line1.bottom, width*(jksizegroupid.count), 1)];
        scrollline1.backgroundColor = [UIColor blackColor];
        scrollline1.top = report.bottom-1;
        [jkscroll addSubview:scrollline1];
        
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(802, 0, 1, 35)];
        line1.backgroundColor = [UIColor blackColor];
        line1.top = report.top;
        [jkView addSubview:line1];
        
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(20, line1.bottom, 152, 1)];
        line2.backgroundColor = [UIColor blackColor];
        line2.top = report.bottom-1;
        [jkView addSubview:line2];
        
        UIView *report1 = [[UIView alloc]initWithFrame:CGRectMake(803, 90+i*35, 199, 35)];
        report1.backgroundColor = [UIColor colorWithRed:239/255.0 green:240/255.0 blue:241/255.0 alpha:1];
        [jkView addSubview:report1];
        
        UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(803, line1.bottom, 199, 1)];
        line3.backgroundColor = [UIColor blackColor];
        line3.top = report1.bottom-1;
        [jkView addSubview:line3];
        
        UILabel *countnumone = [[UILabel alloc]initWithFrame:CGRectMake(812, 90+i*35, 77, 35)];
        countnumone.backgroundColor = [UIColor clearColor];
        NSString *number = [NSString stringWithFormat:@"%d",similarcountnumber];
        countnumone.text = number;
        countnumone.tag = 130001+i;
        countnumone.textAlignment = NSTextAlignmentCenter;
        [jkView addSubview:countnumone];
        [jkcountarr addObject:countnumone.text];
        
        if (numtag==0) {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(875, 90+35*i, 50, 25);
            match.tag = 100001+i;
            [match setTitle:@"搭配" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(suit:) forControlEvents:UIControlEventTouchUpInside];
            [jkView addSubview:match];
            
            
            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(930, 95+35*i, 50, 25);
            proportion.tag = 25000+i;
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            
            
            [jkView addSubview:proportion];
        }
        else
        {
            UIImage *img3 = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
#if ENABLE_RATIO
            
            UIButton *match = [UIButton buttonWithType:UIButtonTypeCustom];
            [match setBackgroundImage:img3 forState:UIControlStateNormal];
            match.frame = CGRectMake(875, 95+35*i, 50, 25);
            match.tag = 30001+i;
            [match setTitle:@"配比" forState:UIControlStateNormal];
            [match addTarget:self action:@selector(match:) forControlEvents:UIControlEventTouchUpInside];
            [jkView addSubview:match];
#else
#endif
            
            UIButton *proportion = [UIButton buttonWithType:UIButtonTypeCustom];
            [proportion setBackgroundImage:img3 forState:UIControlStateNormal];
            proportion.frame = CGRectMake(930, 95+35*i, 50, 25);
            [proportion setTitle:@"清除" forState:UIControlStateNormal];
            proportion.tag = 25000+i;
            [proportion addTarget:self action:@selector(clearOrder:) forControlEvents:UIControlEventTouchUpInside];
            [jkView addSubview:proportion];
        }
        jkView.contentSize = CGSizeMake(jkView.width, jkscroll.contentSize.height+80);
        
    }
//#endif
}

#endif

- (void)tap{
    NSString * path = [[[PMGlobal getInstance] getImageURL] stringByAppendingPathComponent:nowpicUrl];
    NSArray *array = [NSArray arrayWithObject:path];
    PictureViewController *pic = [[PictureViewController alloc] initWithPictures:array withFrame:self.view.frame Desc:nil];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:pic];
    UIImage *img = [[PMGlobal getInstance]getnavigationbarimage];
    [nav.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];

    [self.navigationController presentModalViewController:nav animated:YES];

}
-(void)tap1:(UITapGestureRecognizer *)sender{
    UIView *reportline2 = (UIView *)[view viewWithTag:180000];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    reportline2.top = 35;
    [UIView commitAnimations];
    for (int i = 0; i<sender.view.tag-160000; i++) {
        UIScrollView *similarscroll = (UIScrollView *)[view viewWithTag:170001+i];
        if (i == sender.view.tag -160001) {
            similarscroll.hidden = NO;
        }
        else
        {
            similarscroll.hidden = YES;
        }
        similarscroll.hidden = NO;
        UIView *report = (UIView *)[view viewWithTag:160001+i];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        report.top = 55+36*i;
        [UIView commitAnimations];
    }
    for (int i = sender.view.tag-160000; i<similar.count; i++) {
        UIScrollView *similarscroll = (UIScrollView *)[view viewWithTag:170001+i];
        similarscroll.hidden = YES;
        UIView *report = (UIView *)[view viewWithTag:160001+i];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        report.top = 126+36*i;
        [UIView commitAnimations];
    }
}
-(void)tap2:(UITapGestureRecognizer *)sender{
    UIView *reportline2 = (UIView *)[view viewWithTag:180000];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    reportline2.top = 105;
    [UIView commitAnimations];
    for (int i = 0; i<similar.count; i++) {
        UIScrollView *similarscroll = (UIScrollView *)[view viewWithTag:170001+i];
        similarscroll.hidden = YES;
        UIView *report = (UIView *)[view viewWithTag:160001+i];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        report.top = 126+36*i;
        [UIView commitAnimations];
    }
    iphonescroll.hidden = NO;
}
-(void)tap3:(UITapGestureRecognizer *)sender{
    [edittext resignFirstResponder];
}
-(void)ret
{
    [backview removeFromSuperview];
#ifdef DHH_iOS
    [[NSNotificationCenter defaultCenter]postNotificationName:@"refreshnum" object:nil];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"addsearch" object:nil];
#else
#endif
    /*
    if (numobjtag == 1) {
      //  [self.navigationController.navigationBar setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"navigationbar1.png"] forBarMetrics:UIBarMetricsDefault];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"hidden" object:nil];
    }
     */
//    if (numobjtag != 2) {
//        [[NSNotificationCenter defaultCenter]postNotificationName:@"hidden" object:nil];
//    }
    
    //  [[NSNotificationCenter defaultCenter]postNotificationName:@"refreshorder" object:nil];
    [self.navigationController popViewControllerAnimated:YES];
}

- (NSString *)canSave{
    if (user.inputType!=2) {
        //showMessage(@"该用户不能使用iPad提交订单");
        return @"该用户不能使用iPad提交订单";
    }
    
    ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
    
    if (!shopobj||[shopobj.shopID isEqualToString:@""]||shopobj.shopID == nil) {
//        showMessage(@"用户没有与任何店铺关联，不能提交订单");
        return @"用户没有与任何店铺关联，不能提交订单";
    }
    
    if (shopobj.bCheck) {
//        showMessage(@"该店铺已经审核，不能提交订单");
        return @"该店铺已经审核，不能提交订单";
    }
    
    
    return nil;
}

-(void)save
{
    if ([self canSave]!=nil) {
        showMessage([self canSave]);
        return;
    }
    
    [matchview removeFromSuperview];
    [backview removeFromSuperview];
    isclear1 = YES;
    [self textFieldDidEndEditing:edittext];
    
    UILabel *countnum = (UILabel *)[view viewWithTag:110000];
    SizeObject *sizeobject = [sizegroupid objectAtIndex:0];

    
    if (![countnum.text isEqualToString:@"0"]&&[order getOrder:sizeobject.sSizeNo withShopID:numshopid]==0) {
        [order clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
    }
    
    if ([[countarr objectAtIndex:0]intValue]!=0) {
        if ([countnum.text isEqualToString:@"0"]) {
            [order setOrder:sizeobject.sSizeNo withQuantity:0 withShopID:numshopid];
        }
    }
    [countarr replaceObjectAtIndex:0 withObject:countnum.text];
    if ([[countarr objectAtIndex:0]intValue]!=0) {
        if ([obj.n_beis intValue]>0&&[countnum.text intValue]%[obj.n_beis intValue]) {
            NSString *str = [NSString stringWithFormat:@"您的订单数量应为%@的整数倍",obj.n_beis];
            showMessage(str);
            return;
        }
        if ([countnum.text intValue]<[obj.item5 intValue]) {
            showMessage(@"您的订单数量小于最小起订量");
            return;
        }
    }
    
//    ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
//    NSString *str = [NSString stringWithFormat:@"%@",shopobj.bOrder];
    for (int i = 0; i<similar.count; i++) {
        ProductObject *simobj = [similar objectAtIndex:i];
        OrderObject *orderobj = [orders objectAtIndex:i];
        UILabel *countnum = (UILabel *)[view viewWithTag:110001+i];
        SizeObject *sizeobject = [sizegroupid objectAtIndex:0];
        if ([[countarr objectAtIndex:i+1]intValue]!=0) {
            if ([countnum.text isEqualToString:@"0"]) {
                [orderobj setOrder:sizeobject.sSizeNo withQuantity:0 withShopID:numshopid];
            }
        }
        [countarr replaceObjectAtIndex:i+1 withObject:countnum.text];
        if ([[countarr objectAtIndex:i+1]intValue]!=0) {
            if ([simobj.n_beis intValue]>0&&[countnum.text intValue]%[simobj.n_beis intValue]) {
                NSString *str = [NSString stringWithFormat:@"您的订单数量应为%@的整数倍",simobj.n_beis];
                showMessage(str);
                return;
            }
            if ([countnum.text intValue]<[simobj.item5 intValue]) {
                showMessage(@"您的订单数量小于最小起订量");
                return;
            }
        }
        if (![countnum.text isEqualToString:@"0"]&&[orderobj getOrder:sizeobject.sSizeNo withShopID:numshopid]==0) {
            [orderobj clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
        }
    }
    
#ifdef XLarge_ENABLE
    //有加大的保存加裤信息
    if(bigobj){
        UILabel *countnum = (UILabel *)[bigView viewWithTag:120000];
        
        if (![countnum.text isEqualToString:@"0"]&&[bigorder getOrder:sizeobject.sSizeNo withShopID:numshopid]==0) {
            [bigorder clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
        }
        
        if ([[bigcountarr objectAtIndex:0]intValue]!=0) {
            if ([countnum.text isEqualToString:@"0"]) {
            [bigorder setOrder:sizeobject.sSizeNo withQuantity:0 withShopID:numshopid];
            }
        }
        [bigcountarr replaceObjectAtIndex:0 withObject:countnum.text];
        if ([[bigcountarr objectAtIndex:0]intValue]!=0) {
            if ([countnum.text intValue]%[bigobj.n_beis intValue]) {
                NSString *str = [NSString stringWithFormat:@"您的订单数量应为%@的整数倍",bigobj.n_beis];
                showMessage(str);
                return;
            }
            if ([countnum.text intValue]<[bigobj.item5 intValue]) {
                showMessage(@"您的订单数量小于最小起订量");
                return;
            }
        }
        
        
        for (int i = 0; i<bigsimilar.count; i++) {
            ProductObject *simobj = [bigsimilar objectAtIndex:i];
            OrderObject *orderobj = [bigorders objectAtIndex:i];
            UILabel *countnum = (UILabel *)[bigView viewWithTag:120001+i];
            SizeObject *sizeobject = [sizegroupid objectAtIndex:0];
            if (![countnum.text isEqualToString:@"0"]&&[orderobj getOrder:sizeobject.sSizeNo withShopID:numshopid]==0) {
                [orderobj clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
            }
            if ([[bigcountarr objectAtIndex:i+1]intValue]!=0) {
                if ([countnum.text isEqualToString:@"0"]) {
                [orderobj setOrder:sizeobject.sSizeNo withQuantity:0 withShopID:numshopid];
                }
            }
            [bigcountarr replaceObjectAtIndex:i+1 withObject:countnum.text];
            if ([[bigcountarr objectAtIndex:i+1]intValue]!=0) {
                if ([countnum.text intValue]%[simobj.n_beis intValue]) {
                    NSString *str = [NSString stringWithFormat:@"您的订单数量应为%@的整数倍",simobj.n_beis];
                    showMessage(str);
                    return;
                }
                if ([countnum.text intValue]<[simobj.item5 intValue]) {
                    showMessage(@"您的订单数量小于最小起订量");
                    return;
                }
            }
            
        }
        
    }
    
    //有加裤的保存加裤信息
    if(jkobj){
        UILabel *countnum = (UILabel *)[jkView viewWithTag:130000];
        if (![countnum.text isEqualToString:@"0"]&&[jkorder getOrder:sizeobject.sSizeNo withShopID:numshopid]==0) {
            [jkorder clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
        }
        
        if ([[jkcountarr objectAtIndex:0]intValue]!=0) {
            if ([countnum.text isEqualToString:@"0"]) {
            [jkorder setOrder:sizeobject.sSizeNo withQuantity:0 withShopID:numshopid];
            }
        }
        [jkcountarr replaceObjectAtIndex:0 withObject:countnum.text];
        if ([[jkcountarr objectAtIndex:0]intValue]!=0) {
            if ([countnum.text intValue]%[jkobj.n_beis intValue]) {
                showMessage(@"");
                return;
            }
            if ([countnum.text intValue]<[jkobj.item5 intValue]) {
                showMessage(@"您的订单数量小于最小起订量");
                return;
            }
        }
        
        
        for (int i = 0; i<jksimilar.count; i++) {
            ProductObject *simobj = [jksimilar objectAtIndex:i];
            OrderObject *orderobj = [jkorders objectAtIndex:i];
            UILabel *countnum = (UILabel *)[jkView viewWithTag:130001+i];
            SizeObject *sizeobject = [sizegroupid objectAtIndex:0];
            if (![countnum.text isEqualToString:@"0"]&&[orderobj getOrder:sizeobject.sSizeNo withShopID:numshopid]==0) {
                [orderobj clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
            }
            if ([[jkcountarr objectAtIndex:i+1]intValue]!=0) {
                if ([countnum.text isEqualToString:@"0"]) {
                    [orderobj setOrder:sizeobject.sSizeNo withQuantity:0 withShopID:numshopid];
                }
            }
            [jkcountarr replaceObjectAtIndex:i+1 withObject:countnum.text];
            if ([[jkcountarr objectAtIndex:i+1]intValue]!=0) {
                if ([countnum.text intValue]%[simobj.n_beis intValue]) {
                    showMessage(@"");
                    return;
                }
                if ([countnum.text intValue]<[simobj.item5 intValue]) {
                    showMessage(@"您的订单数量小于最小起订量");
                    return;
                }
            }
            
        }
    }
#endif
    
    NSString *msg = [NSString stringWithFormat:@"正在保存"];
    [WaitTooles showHUD:msg];
    
    
    [[AppManager sharedManager] pauseAutoSubmitSession];
    [[AppManager sharedManager] pauseAutoUpdateSession];
    
    dispatch_queue_t save_queue = dispatch_queue_create("com.yx.pm.save", NULL);
    dispatch_async(save_queue, ^(void) {
        [[DataManager sharedManager]deleteOrderItem:order withSizeNo:nil withTableName:@"g_meeting" Shopid:numshopid];
        for (int i = 0; i<similar.count; i++) {
            OrderObject *orderobj = [orders objectAtIndex:i];
            [[DataManager sharedManager]deleteOrderItem:orderobj withSizeNo:nil withTableName:@"g_meeting" Shopid:numshopid];
        }
        
#ifdef XLarge_ENABLE
        if(bigobj){
            [[DataManager sharedManager]deleteOrderItem:bigorder withSizeNo:nil withTableName:@"g_meeting" Shopid:numshopid];
            
            for (int i = 0; i<bigsimilar.count; i++) {
                OrderObject *orderobj = [bigorders objectAtIndex:i];
                [[DataManager sharedManager]deleteOrderItem:orderobj withSizeNo:nil withTableName:@"g_meeting" Shopid:numshopid];
            }
            
        }
        //有加裤的保存加裤信息
        if(jkobj){
            [[DataManager sharedManager]deleteOrderItem:jkorder withSizeNo:nil withTableName:@"g_meeting" Shopid:numshopid];
            
            for (int i = 0; i<jksimilar.count; i++) {
                OrderObject *orderobj = [jkorders objectAtIndex:i];
                [[DataManager sharedManager]deleteOrderItem:orderobj withSizeNo:nil withTableName:@"g_meeting" Shopid:numshopid];
            }
        }
#endif
        
        if ([obj.n_status intValue] == 0){
            [[DataManager sharedManager]placeOrder:order];
        }
        
        for (int i = 0; i<similar.count; i++) {
            OrderObject *orderobj = [orders objectAtIndex:i];
            ProductObject *product = [similar objectAtIndex:i];
            if ([product.n_status intValue] == 0){
                [[DataManager sharedManager]placeOrder:orderobj];
            }
        }
        
        
        if (bigorder) {
            [[DataManager sharedManager]placeOrder:bigorder];
            for (int i = 0; i<bigsimilar.count; i++) {
                OrderObject *orderobj = [bigorders objectAtIndex:i];
                [[DataManager sharedManager]placeOrder:orderobj];
            }
        }

        if (jkorder) {
            [[DataManager sharedManager]placeOrder:jkorder];
            [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload" object:jkobj];
            for (int i = 0; i<jksimilar.count; i++) {
                OrderObject *orderobj = [jkorders objectAtIndex:i];
                [[DataManager sharedManager]placeOrder:orderobj];
                ProductObject *product = [jksimilar objectAtIndex:i];
                [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload" object:product];
            }
        }
        
        iscopy=YES;
        
        [[AppManager sharedManager] resumeAutoSubmitSession];
        [[AppManager sharedManager] resumeAutoUpdateSession];
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [WaitTooles removeHUD];
            if (isret==YES) {
                [self ret];
            }
            ismodify=NO;
            
            if ([obj.n_status intValue] == 0){
                [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload"
                                                                   object:obj];
            }
            
            for (int i = 0; i<similar.count; i++) {
                ProductObject *product = [similar objectAtIndex:i];
                if ([product.n_status intValue] == 0){
                    [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload"
                                                                       object:product];
                }
            }
            
            [[NSNotificationCenter defaultCenter]postNotificationName:@"ordernumrefresh"
                                                               object:nil];

#ifdef XLarge_ENABLE
            if (bigorder) {
                [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload"
                                                                   object:bigobj];
                for (int i = 0; i<bigsimilar.count; i++) {
                    ProductObject *product = [bigsimilar objectAtIndex:i];
                    [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload"
                                                                       object:product];
                }
            }
            
            if (jkorder) {
                [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload"
                                                                   object:jkobj];
                for (int i = 0; i<jksimilar.count; i++) {
                    ProductObject *product = [jksimilar objectAtIndex:i];
                    [[NSNotificationCenter defaultCenter]postNotificationName:@"numreload"
                                                                       object:product];
                }
            }
#endif
        });
        
    });

    
    
}

-(void)collect:(UIButton *)sender
{
    if (numshopid==nil) {
        [WaitTooles showHUD:@"当前无店铺"];
    }
    else if ([[DataManager sharedManager]productIsFavorite:obj Shopid:numshopid]==0) {
        
        [[DataManager sharedManager]setAsFavorite:obj withStar:sender.tag-10000+1 Shopid:numshopid type:@"0"];
       // [collect setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_redimage.png"] forState:UIControlStateNormal];
        for (int i = 0; i<5; i++) {
            UIButton *btn = (UIButton *)[self.view viewWithTag:10000+i];
            if(i<[[DataManager sharedManager]productIsFavorite:obj Shopid:numshopid])
            {
                [btn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_redimage.png"] forState:UIControlStateNormal];
            }
        }
        [[NSNotificationCenter defaultCenter]postNotificationName:@"collectreload" object:obj];
    }
    else
    {
        //  [collect setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_image.png"] forState:UIControlStateNormal];
        if (sender.tag - 10000+1 == [[DataManager sharedManager]productIsFavorite:obj Shopid:numshopid]) {
            for (int i = 0; i<5; i++) {
                UIButton *btn = (UIButton *)[self.view viewWithTag:10000+i];
                [btn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_image.png"] forState:UIControlStateNormal];
            }
            [[DataManager sharedManager]cancelAsFavorite:obj Shopid:numshopid];
            [[NSNotificationCenter defaultCenter]postNotificationName:@"uncollectreload" object:obj];
        }
        else
        {
            [[DataManager sharedManager]cancelAsFavorite:obj Shopid:numshopid];
            [[DataManager sharedManager]setAsFavorite:obj withStar:sender.tag-10000+1 Shopid:numshopid type:@"0"];
            for (int i = 0; i<5; i++) {
                UIButton *btn = (UIButton *)[self.view viewWithTag:10000+i];
                if(i<[[DataManager sharedManager]productIsFavorite:obj Shopid:numshopid])
                {
                    [btn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_redimage.png"] forState:UIControlStateNormal];
                }
                else
                {
                    [btn setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"collect_image.png"] forState:UIControlStateNormal];
                }
            }
            [[NSNotificationCenter defaultCenter]postNotificationName:@"collectreload" object:obj];
        }
    }
}

- (void)numberInputViewEnterClick:(NSString *)clickValue{
    
}

-(void)numberInputViewDidClick:(NSString *)clickValue
{
    if (isclear1==YES) {
        return;
    }
    
    text.text = clickValue;
    if (text.tag!=1000&&text.tag!=180003) {
        if (text) {
            totalnum = totalnum1 + [text.text intValue] - textnum;
            
            [self refreshTotalQuantityLabel];
        }
        searchtext = nil;
        ismodify = YES;
        countnumber = 0;
        similarcountnumber = 0;
        if (text.tag<100) {
            for(int i = 0;i<sizegroupid.count;i++)
            {
    #ifdef DHH_iOS
            UITextField *textfield = (UITextField *)[iphonescroll viewWithTag:i+10];
          //  NSLog(@"%@",textfield.text);
            countnumber += [textfield.text intValue];
    #else
            UITextField *textfield = (UITextField *)[self.scroll viewWithTag:i+10];
          //  NSLog(@"%@",textfield.text);
                countnumber += [textfield.text intValue];
    #endif
            }
            UILabel *countnum = (UILabel *)[view viewWithTag:110000];
            NSString *num = [NSString stringWithFormat:@"%d",countnumber];
            countnum.text = num;
            countnum.textAlignment = NSTextAlignmentCenter;
            }
            else if(text.tag>=100&&text.tag<1000)
            {
                for(int i = 0;i<sizegroupid.count;i++)
                {
    #ifdef DHH_iOS
                    UITextField *textfield = (UITextField *)[view viewWithTag:text.tag/100*100+i];
                 //   NSLog(@"%@",textfield.text);
                    similarcountnumber += [textfield.text intValue];
    #else
                    UITextField *textfield = (UITextField *)[self.scroll viewWithTag:text.tag/100*100+i];
                 //   NSLog(@"%@",textfield.text);
                    similarcountnumber += [textfield.text intValue];
    #endif
                }
                UILabel *countnumone = (UILabel *)[view viewWithTag:110000+text.tag/100];
                NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
                countnumone.text = num;
                countnumone.textAlignment = NSTextAlignmentCenter;
            }
            else if(text.tag>=140000&&text.tag<140100)
            {
                for(int i = 0;i<sizegroupid.count;i++)
                {
                    UITextField *textfield = (UITextField *)[bigscroll viewWithTag:140000+i+10];
                  //  NSLog(@"%@",textfield.text);
                    countnumber += [textfield.text intValue];
                }
                UILabel *countnum = (UILabel *)[bigView viewWithTag:120000];
                NSString *num = [NSString stringWithFormat:@"%d",countnumber];
                countnum.text = num;
                countnum.textAlignment = NSTextAlignmentCenter;
            }
            else if(text.tag>=140100&&text.tag<141000)
            {
                for(int i = 0;i<sizegroupid.count;i++)
                {
                    UITextField *textfield = (UITextField *)[bigView viewWithTag:text.tag/100*100+i];
                  //  NSLog(@"%@",textfield.text);
                    similarcountnumber += [textfield.text intValue];
                }
                UILabel *countnumone = (UILabel *)[bigView viewWithTag:120000+(text.tag-140000)/100];
                NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
                countnumone.text = num;
                countnumone.textAlignment = NSTextAlignmentCenter;
            }
            else if(text.tag>=150000&&text.tag<150100)
            {
                for(int i = 0;i<jksizegroupid.count;i++)
                {
                    UITextField *textfield = (UITextField *)[jkscroll viewWithTag:150000+i+10];
                  //  NSLog(@"%@",textfield.text);
                    countnumber += [textfield.text intValue];
                }
                UILabel *countnum = (UILabel *)[jkView viewWithTag:130000];
                NSString *num = [NSString stringWithFormat:@"%d",countnumber];
                countnum.text = num;
                countnum.textAlignment = NSTextAlignmentCenter;
            }
            else if(text.tag>=150100&&text.tag<151000)
            {
                for(int i = 0;i<jksizegroupid.count;i++)
                {
                    UITextField *textfield = (UITextField *)[jkscroll viewWithTag:text.tag/100*100+i];
                 //   NSLog(@"%@",textfield.text);
                    similarcountnumber += [textfield.text intValue];
                }
                UILabel *countnumone = (UILabel *)[jkView viewWithTag:130000+(text.tag-150000)/100];
                NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
                countnumone.text = num;
                countnumone.textAlignment = NSTextAlignmentCenter;
            }
        }
    else if(text.tag==180003)
    {
        groupcount = [text.text intValue];
    }
    else
    {
        searchtext = text.text;
    }
    
    [self refreshTotalQuantityLabel];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField.tag==1000) {
    }else{
        ProductObject *product;
        if (textField.tag%10000/100-1<0) {
            product = obj;
        }
        else
        {
            product = [similar objectAtIndex:textField.tag%10000/100-1];
        }
        if ([obj.n_status intValue]==1) {
            [self tap6];
            return NO;
        }
    }
    return YES;
}

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    isclear1=NO;
    iscopy = NO;
    textnum = [textField.text intValue];
    totalnum1 = totalnum;
    edittext = textField;
    if (textField.tag==1000) {
    }
    else
    {
        if (textField.tag==180003) {
            [textField setBackground:[[UIHelper getInstance] getBundleImage:@"match_click.png"]];
        }
        else
        {
            [textField setBackground:[[UIHelper getInstance] getBundleImage:@"order_click.png"]];
        }
        ProductObject *product;
        if (textField.tag%10000/100-1<0) {
            product = obj;
        }
        else
        {
            product = [similar objectAtIndex:textField.tag%10000/100-1];
        }
        NSString *url = [NSString stringWithFormat:@"%@",product.pThumbURL];
        nowpicUrl = product.pURL;
        NSString * path = [[[PMGlobal getInstance] getImageURL] stringByAppendingPathComponent:url];
        path = [path stringByReplacingOccurrencesOfString:@"http:/" withString:@"http://"];
        
        if ([[PMGlobal getInstance]isImageEnable]) {
            productImage_.image = [imageCache_ imageForKey:product.pThumbURL url:[NSURL URLWithString:path] queueIfNeeded:YES tag:0];
            if (!productImage_.image) {
                productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
            }
        }else{
            productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
        }
        
    }
    if ([textField.text isEqualToString:@"0"])
    {
        textField.text = @"";
    }
    text = textField;
    NSString *str = text.text;
    [[NSNotificationCenter defaultCenter]postNotificationName:@"clear" object:str];
    
}
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    return YES;
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField) {
        
        textField.background = [[UIHelper getInstance] getBundleImage:@"clear.png"];
        if (textField.tag != 1000&&textField.tag!=180003) {
            int num = textField.tag;
            
            if ([textField.text isEqualToString:@""]) {
                textField.text = @"0";
            }
            
            int orderNumber = [textField.text intValue];
            
            if (num<100) {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:num-10];
                
//                if (orderNumber!=0) {
                    [order clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
                    [order setOrder:sizeobject.sSizeNo withQuantity:orderNumber withShopID:numshopid];
//                }
            }
            else if(num >=140000&& num<140100)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:num-140000-10];
                
//                if (orderNumber!=0) {
                    [bigorder clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
                    [bigorder setOrder:sizeobject.sSizeNo withQuantity:orderNumber withShopID:numshopid];
//                }
            }
            else if(num >=150000&& num<150100)
            {
                SizeObject *sizeobject = [jksizegroupid objectAtIndex:num-150000-10];
                
//                if (orderNumber!=0) {
                    [jkorder clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
                    [jkorder setOrder:sizeobject.sSizeNo withQuantity:orderNumber withShopID:numshopid];
//                }
            }
            else if(num>=100&&num<1000)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:num%100];
//                if (orderNumber!=0) {
                    [[orders objectAtIndex:num/100-1] clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
                    [[orders objectAtIndex:num/100-1] setOrder:sizeobject.sSizeNo withQuantity:orderNumber withShopID:numshopid];
//                }
            }
            else if(num>=140100 && num <141000)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:num%140000%100];
                
//                if (orderNumber!=0) {
                    [[bigorders objectAtIndex:(num-140000)/100-1] clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
                    [[bigorders objectAtIndex:(num-140000)/100-1] setOrder:sizeobject.sSizeNo withQuantity:orderNumber withShopID:numshopid];
//                }
            }
            else {
                SizeObject *sizeobject = [jksizegroupid objectAtIndex:num%150000%100];
                
//                if (orderNumber!=0) {
                    [[jkorders objectAtIndex:(num-150000)/100-1] clearkey:[NSString stringWithFormat:@"%@_%@",sizeobject.sSizeNo,numshopid]];
                    [[jkorders objectAtIndex:(num-150000)/100-1] setOrder:sizeobject.sSizeNo withQuantity:orderNumber withShopID:numshopid];
//                }
            }
            
            [textField resignFirstResponder];
        }
        else
        {
            if (textField.tag!=1000) {
                textField.background = [[UIHelper getInstance] getBundleImage:@"match_click.png"];
            }
            
            [textField resignFirstResponder];
        }
        text = nil;
    }
    
    
    [self refreshTotalQuantityLabel];
}

#pragma mark 搜索框通知
-(void)search:(NSNotification *)sender
{
    [items removeAllObjects];
    items = [NSMutableArray array];
    if (searchtext&&isclick == NO) {
        
        int cnt =[[[DataManager sharedManager]searchProductCountWithSimCode:searchtext]intValue];
        
        if(cnt == 0)
        {
            showMessage(@"没有找到对应简码");
        }
        else if(cnt >= 1){
            if (ismodify) {
                [self needsave];
            }
            
            searchproduct = [[DataManager sharedManager]searchProductWithSimCode:searchtext];
            if (cnt ==1) {
#ifdef DHH_iOS
                [self iphoneUI:obj shopid:[user.shopID objectAtIndex:0]
                      shopname:user.userName];
#else
                obj = [searchproduct objectAtIndex:0];
                [self ipadUI:obj shopid:numshopid shopname:user.userName tag:0];
#endif
            }
            else{
                
                
                controller = [[ShopViewController alloc] initWithStyle:UITableViewStylePlain items:searchproduct tag:11];
                
                FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller];
                
                //popover.arrowDirection = FPPopoverArrowDirectionAny;
                popover.tint = FPPopoverDefaultTint;
                
                if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
                {
                    popover.contentSize = CGSizeMake(300, 500);
                }
                popover.arrowDirection = FPPopoverArrowDirectionUp;
                
                //sender is the UIButton view
                [popover presentPopoverFromView:codesearch];
            }
        }

    }
    else if(searchtext&&isclick == YES)
    {
        searchproduct = [[DataManager sharedManager] searchProductWithCode:searchtext];
                
        
        controller = [[ShopViewController alloc] initWithStyle:UITableViewStylePlain items:searchproduct tag:11];
        
        FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller];
        
        //popover.arrowDirection = FPPopoverArrowDirectionAny;
        popover.tint = FPPopoverDefaultTint;
        
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            popover.contentSize = CGSizeMake(300, 500);
        }
        popover.arrowDirection = FPPopoverArrowDirectionUp;
        
        //sender is the UIButton view
        [popover presentPopoverFromView:codesearch];

    }
    
    
    UITextField *text1;
#ifdef DHH_iOS
    if (edittext.tag<100) {
        text1 = (UITextField *)[iphonescroll viewWithTag:edittext.tag+1];
    }
    else
    {
        UIScrollView *similarscroll = (UIScrollView *)[view viewWithTag:170000+edittext.tag/100];
        text1 = (UITextField *)[similarscroll viewWithTag:edittext.tag+1];
    }
#else
    if (edittext.tag<1000) {
        text1 = (UITextField *)[self.scroll viewWithTag:edittext.tag+1];
    }
    else if(edittext.tag>=140000&&edittext.tag<150000)
    {
        text1 = (UITextField *)[bigscroll viewWithTag:edittext.tag+1];
    }
    else
    {
        text1 = (UITextField *)[jkscroll viewWithTag:edittext.tag+1];
    }
#endif
    if (text1) {
        [self textFieldDidEndEditing:edittext];
        [text1 becomeFirstResponder];
        [self textFieldDidBeginEditing:text1];
    }
}


-(void)copytoothershop:(UIButton *)sender
{
    if (user.inputType!=2) {
        showMessage(@"该用户不能使用iPad提交订单");
        return;
    }
    
    ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
    if (!shopobj) {
        showMessage(@"用户没有与任何店铺关联，不能提交订单");
        return;
    }
    
    if (iscopy==NO&&ismodify==YES) {
        showMessage(@"复制前请先保存");
    }
    else
    {
    if(shop.count<2)
    {
        showMessage(@"其他店铺不存在");
    }
    else
    {
        [backview removeFromSuperview];
        backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
        backview.userInteractionEnabled=YES;
        [self.view addSubview:backview];
#ifdef DHH_iOS
        UIImage *img = [[UIHelper getInstance] getBundleImage:@"detail_copyback_iphone.png"];
        copytopaste = [[UIImageView alloc]initWithImage:img];
        copytopaste.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        copytopaste.center = CGPointMake(self.view.width/2, self.view.height/2);
        copytopaste.userInteractionEnabled = YES;
        [backview addSubview:copytopaste];
        
        if (sender.tag==184000) {
            iscopyall = NO;
        }
        else if (sender.tag==184001)
        {
            iscopyall = YES;
        }
        UIButton *paste = [UIButton buttonWithType:UIButtonTypeCustom];
        img = [[UIHelper getInstance] getBundleImage:@"anniu_iphone.png"];
        [paste setBackgroundImage:img forState:UIControlStateNormal];
        paste.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        paste.center = CGPointMake([[UIHelper getInstance] getBundleImage:@"detail_copyback_iphone.png"].size.width/2-50, 190);
        [paste setTitle:@"粘贴" forState:UIControlStateNormal];
        [paste addTarget:self action:@selector(pasteclick) forControlEvents:UIControlEventTouchUpInside];
        [copytopaste addSubview:paste];
        
        UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
        [cancel setBackgroundImage:img forState:UIControlStateNormal];
        cancel.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        cancel.center = CGPointMake([[UIHelper getInstance] getBundleImage:@"detail_copyback_iphone.png"].size.width/2+50, 190);
        [cancel setTitle:@"取消" forState:UIControlStateNormal];
        [cancel addTarget:self action:@selector(cancelclick) forControlEvents:UIControlEventTouchUpInside];
        [copytopaste addSubview:cancel];
        
        shoparray = [[NSMutableArray alloc]init];
        ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
        for (int i = 0; i<shop.count; i++) {
            ShopObject *copyshop = [shop objectAtIndex:i];
            if(![shopobj.shopName isEqualToString:copyshop.shopName] &&
               [copyshop.bOrder boolValue])
            {
                [shoparray addObject:copyshop];
            }
        }
        UIScrollView *copyscrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 70, 170, 96)];
        img = [[UIHelper getInstance] getBundleImage:@"detail_copyback_iphone.png"];
        copyscrollview.center = CGPointMake(img.size.width/2,img.size.height/2);
        [copytopaste addSubview:copyscrollview];
        for (int i = 0; i<shoparray.count; i++) {
            ShopObject *copyshop = [shoparray objectAtIndex:i];
            
            shopview = [[UIView alloc]initWithFrame:CGRectMake(0, i*24, 170, 24)];
            shopview.layer.borderWidth = 1;
            shopview.layer.borderColor = [UIColor grayColor].CGColor;
            [copyscrollview addSubview:shopview];
            
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(140, 1, 1, 24)];
            line.backgroundColor = [UIColor grayColor];
            [shopview addSubview:line];
            
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 24)];
            label.center = CGPointMake(70, 12);
            label.textAlignment = NSTextAlignmentCenter;
            label.text = copyshop.shopName;
            label.adjustsFontSizeToFitWidth = YES;
            [shopview addSubview:label];
            
            UIButton *select = [UIButton buttonWithType:UIButtonTypeCustom];
            UIImage *img = [UIImage imageNamed:@"detail_shopunselect.png"];
            [select setImage:img forState:UIControlStateNormal];
            select.frame = CGRectMake(0, 0, img.size.width/2, img.size.height/2);
            select.center = CGPointMake(155, 12);
            select.tag = 10 + i;
            [select addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
            [shopview addSubview:select];
            copyscrollview.contentSize=CGSizeMake(copyscrollview.width, 24*shoparray.count);
        }

#else
        UIImage *img = [[UIHelper getInstance] getBundleImage:@"detail_copyback.png"];
        copytopaste = [[UIImageView alloc]initWithImage:img];
        copytopaste.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        copytopaste.center = CGPointMake(512, 300);
        copytopaste.userInteractionEnabled = YES;
        [backview addSubview:copytopaste];

        if (sender.tag==184000) {
            iscopyall = NO;
        }
        else if (sender.tag==184001)
        {
            iscopyall = YES;
        }
        UIButton *paste = [UIButton buttonWithType:UIButtonTypeCustom];
        [paste setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"anniu.png"] forState:UIControlStateNormal];
        img = [[UIHelper getInstance] getBundleImage:@"detail_paste.png"];
        paste.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        paste.center = CGPointMake([[UIHelper getInstance] getBundleImage:@"detail_copyback.png"].size.width/2-100, 310);
        [paste setTitle:@"粘贴" forState:UIControlStateNormal];
        [paste addTarget:self action:@selector(pasteclick) forControlEvents:UIControlEventTouchUpInside];
        [copytopaste addSubview:paste];
        
        UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
        [cancel setBackgroundImage:[[UIHelper getInstance] getBundleImage:@"anniu.png"] forState:UIControlStateNormal];
        img = [[UIHelper getInstance] getBundleImage:@"detail_cancel.png"];
        cancel.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        cancel.center = CGPointMake([[UIHelper getInstance] getBundleImage:@"detail_copyback.png"].size.width/2+100, 310);
        [cancel setTitle:@"取消" forState:UIControlStateNormal];
        [cancel addTarget:self action:@selector(cancelclick) forControlEvents:UIControlEventTouchUpInside];
        [copytopaste addSubview:cancel];
        
        shoparray = [[NSMutableArray alloc]init];
        ShopObject *shopobj = [[DataManager sharedManager]getCurrentShop];
        for (int i = 0; i<shop.count; i++) {
            ShopObject *copyshop = [shop objectAtIndex:i];
            if(![shopobj.shopName isEqualToString:copyshop.shopName] &&
               [copyshop.bOrder boolValue])
            {
                [shoparray addObject:copyshop];
            }
        }
        UIScrollView *copyscrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 70, 345, 200)];
        img = [[UIHelper getInstance] getBundleImage:@"detail_copyback.png"];
        copyscrollview.center = CGPointMake(img.size.width/2,img.size.height/2);
        [copytopaste addSubview:copyscrollview];
        for (int i = 0; i<shoparray.count; i++) {
            ShopObject *copyshop = [shoparray objectAtIndex:i];
            
            shopview = [[UIView alloc]initWithFrame:CGRectMake(0, i*50, 345, 50)];
            shopview.layer.borderWidth = 1;
            shopview.layer.borderColor = [UIColor grayColor].CGColor;
            [copyscrollview addSubview:shopview];
            
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(290, 1, 1, 50)];
            line.backgroundColor = [UIColor grayColor];
            [shopview addSubview:line];
            
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 30)];
            label.center = CGPointMake(150, 25);
            label.textAlignment = NSTextAlignmentCenter;
            label.text = [NSString stringWithFormat:@"%@  %@",copyshop.shopID,copyshop.shopName];
            label.adjustsFontSizeToFitWidth = YES;
            [shopview addSubview:label];
            
            UIButton *select = [UIButton buttonWithType:UIButtonTypeCustom];
            UIImage *img = [UIImage imageNamed:@"detail_shopunselect.png"];
            [select setImage:img forState:UIControlStateNormal];
            select.frame = CGRectMake(0, 0, img.size.width, img.size.height);
            select.center = CGPointMake(318, 25);
            select.tag = 10 + i;
            [select addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
            [shopview addSubview:select];
            copyscrollview.contentSize=CGSizeMake(copyscrollview.width, 50*shoparray.count);
        }
#endif
    }
    }
}

-(void)keyClicked:(UIButton *)sender
{
    
  //  UIButton *btn = (UIButton *)[view viewWithTag:sender.tag];
  //  [btn setBackgroundColor:[UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1]];
  //  [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  //  [btn setImage:nil forState:UIControlStateNormal];

   // [popup removeFromSuperview];
    [items removeAllObjects];
    items = [NSMutableArray array];
    for (int i = 0;i<shop.count;i++) {
        ShopObject *shopobj = [shop objectAtIndex:i];
        [items addObject:shopobj.shopName];
    }
    /*
    popup = [[PopupView alloc] initWithFrame:sender.frame withItems:items withHighlight:0 width:sender.left+35 tag:sender.tag];
    popup.delegate = self;
    [self.view addSubview:popup];
     */
    //the controller we want to present as a popover
    controller = [[ShopViewController alloc] initWithStyle:UITableViewStylePlain items:items tag:sender.tag];
    
    FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller];
    
    //popover.arrowDirection = FPPopoverArrowDirectionAny;
    popover.tint = FPPopoverDefaultTint;
    
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        popover.contentSize = CGSizeMake(300, 500);
    }
    popover.arrowDirection = FPPopoverArrowDirectionUp;
    
    //sender is the UIButton view
    [popover presentPopoverFromView:sender];
}



-(void)getshop
{
    
}

-(void)pasteclick
{
    [shopidarray removeAllObjects];
   // [orders removeAllObjects];
    for (int i = 0; i<shoparray.count; i++) {
        UIButton *btn = (UIButton *)[copytopaste viewWithTag:10+i];
        if (btn.imageView.image == [UIImage imageNamed:@"detail_shopunselect.png"]) {
            [shopidarray addObject:@"0"];
        }
        else {
            [shopidarray addObject:@"1"];
        }
    }
    for (int i = 0; i<shopidarray.count; i++) {
        if ([[shopidarray objectAtIndex:i] isEqualToString:@"1"]) {
            ShopObject *shopobj = [shoparray objectAtIndex:i];
            ShopObject *currentshop = [[DataManager sharedManager]getCurrentShop];
            if (iscopyall==YES) {
                [[DataManager sharedManager]Copyorder:user.userCode code:nil FromShopid:currentshop.shopID ToShopid:shopobj.shopID withTime:1];
            }
            else
            {
                [[DataManager sharedManager]Copyorder:user.userCode code:nil FromShopid:currentshop.shopID ToShopid:shopobj.shopID withTime:1];
            }
        }
    }
    
    showMessage(@"复制完毕");
    
    [backview removeFromSuperview];
}
/*
-(void)dismiss:(NSNotification *)sender
{
    NSString *tag = sender.object;
    UIButton *btn = (UIButton *)[view viewWithTag:[tag intValue]];
    [btn setBackgroundColor:[UIColor clearColor]];
    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [btn setImage:[[UIHelper getInstance] getBundleImage:@"order_next.png"] forState:UIControlStateNormal];
    isclear = YES;
}
*/
-(void)cancelclick
{
    [backview removeFromSuperview];
    backview = nil;
}

-(void)click:(UIButton *)sender
{
    ShopObject *copyshop = [shoparray objectAtIndex:sender.tag-10];
    
    if (copyshop.bCheck) {
        showMessage(@"该店铺已经审核，不能提交订单");
        return;
    }
    
    
    UIButton *btn = (UIButton *)[copytopaste viewWithTag:sender.tag];
#ifdef DHH_iOS
    if(btn.imageView.image == [UIImage imageNamed:@"detail_shopunselect.png"])
    {
        NSString *str = [NSString stringWithFormat:@"%@",copyshop.bOrder];
        if ([str isEqualToString:@"0"]) {
            showMessage(@"您没有对该店铺提交订单的权限");
            return;
        }
        UIImage *img = [UIImage imageNamed:@"detail_shopselect.png"];
        [btn setImage:img forState:UIControlStateNormal];
        btn.frame = CGRectMake(0, 0, img.size.width/2, img.size.height/2);
        btn.center = CGPointMake(157, 11);
    }
    else
    {
        UIImage *img = [UIImage imageNamed:@"detail_shopunselect.png"];
        [btn setImage:img forState:UIControlStateNormal];
        btn.frame = CGRectMake(0, 0, img.size.width/2, img.size.height/2);
        btn.center = CGPointMake(155, 12);
    }
#else
    
    if(btn.imageView.image == [UIImage imageNamed:@"detail_shopunselect.png"])
    {
        NSString *str = [NSString stringWithFormat:@"%@",copyshop.bOrder];
        if ([str isEqualToString:@"0"]) {
            showMessage(@"您没有对该店铺提交订单的权限");
            return;
        }
        UIImage *img = [UIImage imageNamed:@"detail_shopselect.png"];
        [btn setImage:img forState:UIControlStateNormal];
        btn.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        btn.center = CGPointMake(322, 22);

    }
    else
    {
        UIImage *img = [UIImage imageNamed:@"detail_shopunselect.png"];
        [btn setImage:img forState:UIControlStateNormal];
        btn.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        btn.center = CGPointMake(318, 25);
    }
#endif
}

#pragma mark
- (void)popupViewClicked:(PopupView *)popup atIndex:(int)clickedIndex{
    ShopObject *shopobj = [shop objectAtIndex:clickedIndex];
    [self ipadUI:obj shopid:shopobj.shopID shopname:shopobj.shopName tag:0];
}

#pragma mark 点击店铺通知
-(void)index1:(NSNotification *)sender
{
    NSString *str = sender.object;
    int index = [str intValue];
    ShopObject *shopobj = [shop objectAtIndex:index];
#ifdef DHH_iOS
    [self iphoneUI:obj shopid:shopobj.shopID
          shopname:shopobj.shopName];
#else
    [self ipadUI:obj shopid:shopobj.shopID shopname:shopobj.shopName tag:0];
#endif
    [[NSNotificationCenter defaultCenter]postNotificationName:@"dismissPopover" object:nil];
}

-(void)selectcode:(UIButton *)sender
{
//    if (ismodify==YES) {
//        [self needsave];
//    }
    //[codesearch removeFromSuperview];
    if(isclick == NO)
    {
        codesearch.placeholder = SEARCH_CODENAME;
       // [sender setTitle:@"简码搜索" forState:UIControlStateNormal];
        showMessage([NSString stringWithFormat:@"切换成%@",SEARCH_CODENAME]);
        isclick = YES;
        [[NSNotificationCenter defaultCenter]postNotificationName:@"setsearchbtn1" object:@"0"];
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        [def setObject:@"1" forKey:@"setsearchbtn"];
        [def synchronize];
    }
    else
    {
        codesearch.placeholder = SEARCH_SIMCODE;
        showMessage([NSString stringWithFormat:@"切换成%@",SEARCH_SIMCODE]);
        isclick = NO;
        [[NSNotificationCenter defaultCenter]postNotificationName:@"setsearchbtn1" object:@"1"];
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        [def setObject:@"0" forKey:@"setsearchbtn"];
        [def synchronize];
    }
}

#pragma mark 模糊搜索弹出poperview框点击通知
-(void)coderefresh:(NSNotification *)sender
{
    NSString *num = sender.object;
    obj = [searchproduct objectAtIndex:[num intValue]];
    [self ipadUI:obj shopid:numshopid shopname:nil tag:1];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"dismissPopover" object:nil];
}

-(void)suit:(UIButton *)sender
{
    if (sender.tag == 100000) {
        NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
        NSString *colorcode = obj.pColorCode;
        [dic setObject:obj.pCode forKey:@"code"];
        [dic setObject:colorcode forKey:@"color"];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"suitrefresh" object:dic];
        [self.navigationController popViewControllerAnimated:YES];
    }
    else
    {
        ProductObject *product = [similar objectAtIndex:sender.tag-100001];
        NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
        NSString *colorcode = product.pColorCode;
        [dic setObject:product.pCode forKey:@"code"];
        [dic setObject:colorcode forKey:@"color"];
        NSArray *suits_ = [[DataManager sharedManager] GetSuitArrayByCode:product.pCode ColorId:colorcode];
        if (suits_.count>0) {
            [[NSNotificationCenter defaultCenter]postNotificationName:@"suitrefresh" object:dic];
            [self.navigationController popViewControllerAnimated:YES];
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"此产品没有对应配装" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
        }
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0) {
        if (self.isViewLoaded && !self.view.window)
        {
            self.view = nil;
        }
    }
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
#ifdef DHH_iOS
    return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);
#else
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
#endif
}

- (BOOL)shouldAutorotate{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations{
#ifdef DHH_iOS
    return UIInterfaceOrientationMaskPortrait;
#else
    return UIInterfaceOrientationMaskLandscape;
#endif
}

#pragma mark 显示产品图片
- (void)product_detail_image:(NSNotification *)notification{
    NSDictionary *dict = [notification userInfo];
    UIImage *img = [dict objectForKey:@"image"];
    //int tag = [[dict objectForKey:@"tag"] intValue];
    
    if ([[PMGlobal getInstance]isImageEnable]) {
        if (img) {
            productImage_.image = img;
        }else{
        }
    }else{
        productImage_.image = [[UIHelper getInstance] getBundleImage:@"product_placeholder.jpg"];;
    }
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [edittext resignFirstResponder];
   // [self textFieldShouldEndEditing:edittext];
}
-(void)zbar:(UIButton *)sender
{
//    ZbarViewController *zbar = [[ZbarViewController alloc]init];
//    [self.navigationController pushViewController:zbar animated:YES];
//    ZBarReaderViewController *reader = [ZBarReaderViewController new];
//    reader.readerDelegate = self;
//    reader.supportedOrientationsMask = ZBarOrientationMaskAll;
//#ifdef DHH_iOS
//    UIImage *img = [[UIHelper getInstance] getBundleImage:@"croprect_iphone.png"];
//    UIImageView *imageview = [[UIImageView alloc]initWithImage:img];
//    imageview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
//    imageview.center = CGPointMake(160, 190);
//    [reader.view addSubview:imageview];
//    
//    img = [[UIHelper getInstance] getBundleImage:@"croptip_iphone.png"];
//    UIImageView *tipimageview = [[UIImageView alloc]initWithImage:img];
//    tipimageview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
//    tipimageview.centerX = imageview.centerX;
//    tipimageview.top = imageview.bottom;
//    [reader.view addSubview:tipimageview];
//#else
//    UIImage *img = [[UIHelper getInstance] getBundleImage:@"croprect.png"];
//    UIImageView *imageview = [[UIImageView alloc]initWithImage:img];
//    imageview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
//    imageview.center = CGPointMake(512, 368);
//    [reader.view addSubview:imageview];
//    
//    img = [[UIHelper getInstance] getBundleImage:@"croptip.png"];
//    UIImageView *tipimageview = [[UIImageView alloc]initWithImage:img];
//    tipimageview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
//    tipimageview.centerX = imageview.centerX;
//    tipimageview.top = imageview.bottom;
//    [reader.view addSubview:tipimageview];
//#endif
//    CGRect scanMaskRect;
//    if ([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0)
//    {
//        scanMaskRect = CGRectMake(0, 0, imageview.size.width, imageview.size.height);
//    }
//    else
//    {
//        scanMaskRect = CGRectMake(0, 0, 1024, 768);
//    }
//    reader.scanCrop = [self getScanCrop:scanMaskRect readerViewBounds:reader.view.bounds];
//    
//    ZBarImageScanner *scanner = reader.scanner;
//    
//    [scanner setSymbology: ZBAR_I25
//                   config: ZBAR_CFG_ENABLE
//                       to: 0];
//
//    
//    [self presentModalViewController: reader
//                            animated: YES];
}
//- (void) imagePickerController: (UIImagePickerController*) reader
// didFinishPickingMediaWithInfo: (NSDictionary*) info
//{
//    id<NSFastEnumeration> results =
//    [info objectForKey: ZBarReaderControllerResults];
//    ZBarSymbol *symbol = nil;
//    for(symbol in results)
//        break;
//    
//    zbarimageview.image =
//    [info objectForKey: UIImagePickerControllerOriginalImage];
//    
//    [reader dismissModalViewControllerAnimated: YES];
//    
//    //判断是否包含 头'http:'
//    NSString *regex = @"http+:[^\\s]*";
//    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
//    
//    //判断是否包含 头'ssid:'
//    NSString *ssid = @"ssid+:[^\\s]*";;
//    NSPredicate *ssidPre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",ssid];
//    
//  //  zbarlabel.text =  symbol.data ;
//    int cnt =[[[DataManager sharedManager]searchProductCountWithSimCode:symbol.data]intValue];
//    if(cnt == 0)
//    {
//        NSString *str=[NSString stringWithFormat:@"没有找到简码%@",symbol.data];
//        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:str delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
//        [alert show];
//    }
//    else if(cnt >= 1){
//        searchproduct = [[DataManager sharedManager]searchProductWithSimCode:symbol.data];
//        if (cnt ==1) {
//#ifdef DHH_iOS
//            [self iphoneUI:obj shopid:[user.shopID objectAtIndex:0]
//                  shopname:user.userName];
//#else
//            obj = [searchproduct objectAtIndex:0];
//            [self ipadUI:obj shopid:numshopid shopname:user.userName tag:0];
//#endif
//        }
//    }
//    if ([predicate evaluateWithObject:zbarlabel.text]) {
//        
//        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil
//                                                        message:@"It will use the browser to this URL。"
//                                                       delegate:nil
//                                              cancelButtonTitle:@"Close"
//                                              otherButtonTitles:@"Ok", nil];
//        alert.delegate = self;
//        alert.tag=1;
//        [alert show];
//        
//        
//        
//    }
//    else if([ssidPre evaluateWithObject:zbarlabel.text]){
//        
//        NSArray *arr = [zbarlabel.text componentsSeparatedByString:@";"];
//        
//        NSArray * arrInfoHead = [[arr objectAtIndex:0] componentsSeparatedByString:@":"];
//        
//        NSArray * arrInfoFoot = [[arr objectAtIndex:1] componentsSeparatedByString:@":"];
//        
//        
//        zbarlabel.text=
//        [NSString stringWithFormat:@"ssid: %@ \n password:%@",
//         [arrInfoHead objectAtIndex:1],[arrInfoFoot objectAtIndex:1]];
//        
//        
//        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:zbarlabel.text
//                                                        message:@"The password is copied to the clipboard , it will be redirected to the network settings interface"
//                                                       delegate:nil
//                                              cancelButtonTitle:@"Close"
//                                              otherButtonTitles:@"Ok", nil];
//        
//        
//        alert.delegate = self;
//        alert.tag=2;
//        [alert show];
//        
//        UIPasteboard *pasteboard=[UIPasteboard generalPasteboard];
//        //        然后，可以使用如下代码来把一个字符串放置到剪贴板上：
//        pasteboard.string = [arrInfoFoot objectAtIndex:1];
//        
//        
//    }
//}
-(void)match:(UIButton *)sender
{
    btntag=sender.tag;
    if (btntag>=185000) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"该款为取消款" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        return;
    }
    /*
    [backview removeFromSuperview];
    backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    backview.userInteractionEnabled=YES;
    [self.view addSubview:backview];
     */
#ifdef DHH_iOS
    UIImage *img = [UIImage imageNamed:@"issavebackimage.png"];
    matchview = [[UIImageView alloc]initWithImage:img];
    matchview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    matchview.center=CGPointMake(160, 240);
    matchview.backgroundColor = [UIColor clearColor];
    matchview.userInteractionEnabled = YES;
    [self.view addSubview:matchview];
#else
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"issavebackimage.png"];
    matchview = [[UIImageView alloc]initWithImage:img];
    matchview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    matchview.center=CGPointMake(512, 384);
    matchview.backgroundColor = [UIColor clearColor];
    matchview.userInteractionEnabled = YES;
    [self.view addSubview:matchview];
#endif
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 40)];
    title.centerX = matchview.width/2;
    title.top = 50;
    title.text=@"请输入组数";
    title.font = [UIFont systemFontOfSize:25];
    title.textAlignment=UITextAlignmentCenter;
    [matchview addSubview:title];
#ifdef DHH_iOS
    UITextField *count = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    count.top=100;
    count.centerX = matchview.width/2;
  //  count.backgroundColor = [UIColor grayColor];
    [count setBackground:[[UIHelper getInstance] getBundleImage:@"match_click.png"]];
    count.delegate = self;
    count.inputView = input;
    count.textColor = [UIColor blackColor];
    count.textAlignment=UITextAlignmentCenter;
    count.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    count.tag=180003;
    [matchview addSubview:count];
#else
    UIView* dummyView = [[UIView alloc] initWithFrame:CGRectZero];
    UITextField *count = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    count.top=100;
    count.centerX = matchview.width/2;
//    count.backgroundColor = [UIColor grayColor];
    [count setBackground:[[UIHelper getInstance] getBundleImage:@"match_click.png"]];
    count.delegate = self;
    count.inputView = dummyView;
    count.textColor = [UIColor blackColor];
    count.textAlignment=UITextAlignmentCenter;
    count.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    count.tag=180003;
    [matchview addSubview:count];
#endif
    UIButton *sure = [UIButton buttonWithType:UIButtonTypeCustom];
    img = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
    [sure setBackgroundImage:img forState:UIControlStateNormal];
    [sure setTitle:@"确定" forState:UIControlStateNormal];
    sure.frame = CGRectMake(0, 0, img.size.width*1.3, img.size.height*1.3);
    sure.top=180;
    sure.centerX = matchview.width/2-90;
    [sure addTarget:self action:@selector(sure) forControlEvents:UIControlEventTouchUpInside];
    [matchview addSubview:sure];
    
    UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancel setBackgroundImage:img forState:UIControlStateNormal];
    [cancel setTitle:@"取消" forState:UIControlStateNormal];
    cancel.frame = CGRectMake(0, 0, img.size.width*1.3, img.size.height*1.3);
    cancel.top=180;
    cancel.centerX = matchview.width/2+90;
    [cancel addTarget:self action:@selector(cancelled1) forControlEvents:UIControlEventTouchUpInside];
    [matchview addSubview:cancel];
}

-(void)issave
{
    isret=YES;
    
    if ( [self canSave]==nil && ismodify==YES) {
        [self needsave];
    }
    else
    {
        [self ret];
    }
}
- (void)sure
{
    [matchview removeFromSuperview];
    countnumber=0;
    similarcountnumber=0;
    ismodify=YES;
    NSArray *sizenum = [[DataManager sharedManager]getmatching:obj.pSerial childtype:obj.pType];
#ifdef DHH_iOS
    if (btntag%10000==0&&sizenum.count>0) {
        if (btntag>=100000) {
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[iphonescroll viewWithTag:i+10];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [order setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                countnumber+=[textfield.text intValue];
            }
            UILabel *countnum = (UILabel *)[view viewWithTag:110000];
            totalnum -= [countnum.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",countnumber];
            countnum.text = num;
            countnum.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnum.text intValue];
            
            [self refreshTotalQuantityLabel];
        }
        else if(btntag>=20000&&btntag<30000)
        {
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[bigscroll viewWithTag:140000+i+10];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [bigorder setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                countnumber+=[textfield.text intValue];
            }
            UILabel *countnum = (UILabel *)[bigView viewWithTag:120000];
            totalnum -= [countnum.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",countnumber];
            countnum.text = num;
            countnum.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnum.text intValue];
            [self refreshTotalQuantityLabel];
        }
    }
    else if(btntag%10000>0&&sizenum.count>0)
    {
        if (btntag>=100000) {
            OrderObject *order1 = [orders objectAtIndex:btntag-100001];
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[view viewWithTag:100*(btntag-100000)+i];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [order1 setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                similarcountnumber+=[textfield.text intValue];
            }
            UILabel *countnumone = (UILabel *)[view viewWithTag:110000+(btntag-100000)];
            totalnum -= [countnumone.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
            countnumone.text = num;
            countnumone.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnumone.text intValue];
            [self refreshTotalQuantityLabel];
        }
        else if(btntag>=20000&&btntag<30000)
        {
            OrderObject *order1 = [bigorders objectAtIndex:btntag-20001];
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[bigscroll viewWithTag:140000+100*(btntag-100000)+i];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [order1 setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                similarcountnumber+=[textfield.text intValue];
            }
            UILabel *countnumone = (UILabel *)[bigView viewWithTag:120000+(btntag-20000)];
            totalnum -= [countnumone.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
            countnumone.text = num;
            countnumone.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnumone.text intValue];
            [self refreshTotalQuantityLabel];
        }
    }
#else
    if (btntag%10000==0&&sizenum.count>0) {
        if (btntag>=100000) {
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[self.scroll viewWithTag:i+10];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [order setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                countnumber+=[textfield.text intValue];
            }
            UILabel *countnum = (UILabel *)[view viewWithTag:110000];
            totalnum -= [countnum.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",countnumber];
            countnum.text = num;
            countnum.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnum.text intValue];
            [self refreshTotalQuantityLabel];
        }
        else if(btntag>=20000&&btntag<30000)
        {
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[bigscroll viewWithTag:140000+i+10];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [bigorder setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                countnumber+=[textfield.text intValue];
            }
            UILabel *countnum = (UILabel *)[bigView viewWithTag:120000];
            totalnum -= [countnum.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",countnumber];
            countnum.text = num;
            countnum.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnum.text intValue];
            [self refreshTotalQuantityLabel];
        }
    }
    else if(btntag%10000>0&&sizenum.count>0)
    {
        if (btntag>=100000) {
            OrderObject *order1 = [orders objectAtIndex:btntag-100001];
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[self.scroll viewWithTag:100*(btntag-100000)+i];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [order1 setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                similarcountnumber+=[textfield.text intValue];
            }
            UILabel *countnumone = (UILabel *)[view viewWithTag:110000+(btntag-100000)];
            totalnum -= [countnumone.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
            countnumone.text = num;
            countnumone.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnumone.text intValue];

            [self refreshTotalQuantityLabel];
        }
        else if(btntag>=20000&&btntag<30000)
        {
            OrderObject *order1 = [bigorders objectAtIndex:btntag-20001];
            for(int i=0;i<sizegroupid.count;i++)
            {
                SizeObject *sizeobject = [sizegroupid objectAtIndex:i];
                UITextField *textfield=(UITextField *)[bigscroll viewWithTag:140000+100*(btntag-100000)+i];
                int num = [[sizenum objectAtIndex:i]intValue]*groupcount;
                NSString *str = [NSString stringWithFormat:@"%d",num];
                textfield.text=str;
                [order1 setOrder:sizeobject.sSizeNo withQuantity:num withShopID:numshopid];
                similarcountnumber+=[textfield.text intValue];
            }
            UILabel *countnumone = (UILabel *)[bigView viewWithTag:120000+(btntag-20000)];
            totalnum -= [countnumone.text intValue];
            NSString *num = [NSString stringWithFormat:@"%d",similarcountnumber];
            countnumone.text = num;
            countnumone.textAlignment = NSTextAlignmentCenter;
            totalnum += [countnumone.text intValue];
            
            [self refreshTotalQuantityLabel];
        }
    }
#endif
}
-(void)cancelled
{
    if (isret==YES) {
        [self ret];
    }
    [matchview removeFromSuperview];
    [backview removeFromSuperview];
}
-(void)cancelled1
{
    [matchview removeFromSuperview];
    [backview removeFromSuperview];
}

- (void)tap4{
    [edittext resignFirstResponder];
}

-(BOOL)isminnum
{
    for (int i=0; i<similar.count+1; i++) {
        UILabel *num = (UILabel *)[view viewWithTag:110000+i];
        NSString *minnumstr = [NSString stringWithFormat:@"%@",num.text];
        if ([minnumstr intValue]<minnum&&[minnumstr intValue]!=0) {
            return NO;
        }
    }
    return YES;
}

-(void)tap5
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"该尺码不可用" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alert show];
}
-(void)tap6
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"该款为取消款" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alert show];
}
-(void)refreshisordering
{
    if (countarr.count>0) {
        if ([countarr objectAtIndex:0]>0) {
            obj.isordering=YES;
        }
        else
        {
            obj.isordering=NO;
        }
        for (int i=0; i<similar.count; i++) {
            ProductObject *simobj=[similar objectAtIndex:i];
            if ([countarr objectAtIndex:i+1]>0) {
                simobj.isordering=YES;
            }
            else
            {
                simobj.isordering=NO;
            }
        }
    }
}

-(void)showtip:(NSNotification *)sender
{
    NSArray *tips = [[DataManager sharedManager]getTipsarray];
    if (tips.count==0) {
        return;
    }
    NSDictionary *tipdic = [tips objectAtIndex:tips.count-1];
    
    [self performSelectorOnMainThread:@selector(addTipView:) withObject:tipdic waitUntilDone:YES];
    
}

- (void)addTipView:(NSDictionary *)dic{
    TipView *tipview = [[TipView alloc]initWithdic:dic];
    [self.navigationController.view addSubview:tipview];
}

-(CGRect)getScanCrop:(CGRect)rect readerViewBounds:(CGRect)readerViewBounds
{
    CGFloat x,y,width1,height;
    
    x = rect.origin.x / readerViewBounds.size.width;
    y = rect.origin.y / readerViewBounds.size.height;
    width1 = rect.size.width / readerViewBounds.size.width;
    height = rect.size.height / readerViewBounds.size.height;
    
    return CGRectMake(x, y, width1, height);
}

- (void)comfirmSearch:(UIButton *)button{
    [[NSNotificationCenter defaultCenter]postNotificationName:@"search" object:nil];
}

-(void)clicktap:(UITapGestureRecognizer *)sender
{
    [[NSNotificationCenter defaultCenter]postNotificationName:@"search" object:nil];
}

-(void)needsave
{
    [backview removeFromSuperview];
    backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    backview.userInteractionEnabled=YES;
    [self.view addSubview:backview];
#ifdef DHH_iOS
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"issavebackimage.png"];
    issaveview = [[UIImageView alloc]initWithImage:img];
    issaveview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    issaveview.center=CGPointMake(160, 240);
    issaveview.backgroundColor = [UIColor clearColor];
    issaveview.userInteractionEnabled = YES;
    [backview addSubview:issaveview];
#else
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"issavebackimage.png"];
    issaveview = [[UIImageView alloc]initWithImage:img];
    issaveview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
    issaveview.center=CGPointMake(512, 384);
    issaveview.backgroundColor = [UIColor clearColor];
    issaveview.userInteractionEnabled = YES;
    [backview addSubview:issaveview];
#endif
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 40)];
    title.centerX = issaveview.width/2;
    title.backgroundColor = [UIColor clearColor];
    title.top = 80;
    title.text=@"是否需要保存";
    title.font = [UIFont systemFontOfSize:25];
    title.textAlignment=UITextAlignmentCenter;
    [issaveview addSubview:title];
    
    UIButton *sure = [UIButton buttonWithType:UIButtonTypeCustom];
    img = [[UIHelper getInstance] getBundleImage:@"anniu.png"];
    [sure setBackgroundImage:img forState:UIControlStateNormal];
    [sure setTitle:@"确定" forState:UIControlStateNormal];
    sure.frame = CGRectMake(0, 0, img.size.width*1.3, img.size.height*1.3);
    sure.top=165;
    sure.centerX = issaveview.width/2-90;
    [sure addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
    [issaveview addSubview:sure];
    
    UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancel setBackgroundImage:img forState:UIControlStateNormal];
    [cancel setTitle:@"取消" forState:UIControlStateNormal];
    cancel.frame = CGRectMake(0, 0, img.size.width*1.3, img.size.height*1.3);
    cancel.top=165;
    cancel.centerX = issaveview.width/2+90;
    [cancel addTarget:self action:@selector(cancelled) forControlEvents:UIControlEventTouchUpInside];
    [issaveview addSubview:cancel];
}

-(void)setsearchbtn:(NSNotification *)sender
{
    NSString *str = sender.object;
    if([str isEqualToString:@"0"])
    {
        codesearch.placeholder = [NSString  stringWithFormat:@"款号%@",SEARCH_CODENAME];
        
        // [sender setTitle:@"简码搜索" forState:UIControlStateNormal];
        showMessage([NSString stringWithFormat:@"切换成%@",SEARCH_CODENAME]);
        isclick = YES;
    }
    else
    {
        codesearch.placeholder = SEARCH_SIMCODE;
        showMessage([NSString stringWithFormat:@"切换成%@",SEARCH_SIMCODE]);
        isclick = NO;
    }
}

- (void)refreshTotalQuantityLabel{
    NSString *str = [NSString stringWithFormat:@"订单总量：%d",[self getTotalQuantity]];
    totallabel.text = str;
}

- (int)getTotalQuantity{
    int num = 0;
    
    num += [order getTotalOrderNumber];
    
#ifdef XLarge_ENABLE
    
    num += [bigorder getTotalOrderNumber];
    
    for (OrderObject *sOrder in  bigsimilar) {
        num += [sOrder getTotalOrderNumber];
    }
    
    num += [jkorder getTotalOrderNumber];
    
#endif
    
    for (OrderObject *sOrder in orders) {
        num += [sOrder getTotalOrderNumber];
    }
    
    return num;
}
@end
